Skip to content

Instantly share code, notes, and snippets.

@wiratama
wiratama / sn-web-log
Created September 3, 2020 08:45
SN Web log, platfom.sh deploy tools
macminis-Mini:SnWebPlatformSh macmini$ git push origin master
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 481 bytes | 481.00 KiB/s, done.
Total 6 (delta 5), reused 0 (delta 0)
Validating submodules
Validating configuration files
GET /sso/auth?response_type=code&action=login&client_id=19_i94gh6pei2ygukzzd0s7xf318for9hl77punohkgq2j31642wb&redirect_uri=https%3A%2F%2Fn4hk.otesuto.com%2Fredirect&scope=user HTTP/1.1
Host: beta.connect.sahabatnestle.co.id
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Sec-Fetch-Site: cross-site
Referer: https://n4hk.otesuto.com/loginsoo
<?php
public function checkauth() {
$config = $this->config('snsso.settings');
$authCode = null;
$user = null;
if (isset($_GET['code'])) {
if ($_GET['code']) $authCode = $_GET['code'];
}
@wiratama
wiratama / drupal-has-many
Last active August 8, 2019 10:03
avoid n+1 query on drupal custom module
public function yourMethodName()
{
$user_claims = $grouped_claims = [];
$claims = \Drupal::database()->select('crm_claim', 'cc')
->fields('cc')
->condition('user_id', $this->field_sso_id)
->extend('Drupal\Core\Database\Query\PagerSelectExtender')->limit($this->limit_content)
->execute()->fetchAll();
@wiratama
wiratama / ThemeNegotiator.php
Created April 4, 2019 02:40 — forked from jimconte/ThemeNegotiator.php
A sample class implementation of Drupal 8's ThemeNegotiatorInterface from https://jimconte.com/blog/web/dynamic-theme-switching-in-drupal-8
<?php
/**
* @file
* Contains \Drupal\jcmodule\Theme\ThemeNegotiator
*/
namespace Drupal\jcmodule\Theme;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Theme\ThemeNegotiatorInterface;
Creating custom table in drupal 8 is not recommended. Create entity types instead.
But if you want to Create custom table you can create either by implementing hook_schema or
else create schema file config/schema/your_custom_module_name.schema.yml in your module
(https://www.drupal.org/docs/8/api/configuration-api/configuration-schemametadata).
( https://drupal.stackexchange.com/questions/219580/best-practice-for-creating-table-in-custom-module )
1. Implementing hook_schema in .module file (Not recommended).
/**
@wiratama
wiratama / backup.bat
Created October 31, 2018 15:43 — forked from malkitsingh/backup.bat
batch file to run mongodb daily tasks
@echo off
REM move into the backups directory
CD C:\backup
REM Create a file name for the database output which contains the date and time. Replace any characters which might cause an issue.
set filename=database %date% %time%
set filename=%filename:/=-%
set filename=%filename: =__%
set filename=%filename:.=_%
<?php
namespace Movent\ContentBundle\Twig;
use Movent\ContentBundle\Permalink\PermalinkInterface;
use Movent\ContentBundle\Entity\Interfaces\ContentInterface;
use Movent\ContentBundle\Entity\Interfaces\ArticleInterface;
use Movent\ContentBundle\Entity\Interfaces\RecipeInterface;
use Movent\ContentBundle\Entity\Interfaces\ProductInterface;
use Movent\CategoryBundle\Entity\CategoryInterface;
....
public function itemproductAction(Request $request)
{
$contentId = $request->get('content_id');
$categoryId = $request->get('category_id');
$isDefault = $request->get('is_default', false);
$isMini = $request->get('is_mini', false);
$category = null;
{% extends 'MoventContentBundle:Content/Layout/base:base.html.twig' %}
{% block content %}
{% include "MoventSiteBundle:Social:socialinit.html.twig" %}
<div class="main innerpage">
<div class="wrapper-center">
<div id="product-{{ object.id }}" class="productdetail">
<div class="recipe-header-breadcrumbs">
{{ sonata_block_render_event('breadcrumb', { 'context': 'content_view', 'category': category}) }}
</div>