Skip to content

Instantly share code, notes, and snippets.

View St0iK's full-sized avatar
☘️
🇬🇷

Dimitris Stoikidis St0iK

☘️
🇬🇷
View GitHub Profile
@St0iK
St0iK / Composite.md
Last active May 27, 2019 21:07
Composite Pattern

Composite

Com­pos­ite is a struc­tur­al design pat­tern that lets you com­pose objects into tree struc­tures and then work with these struc­tures as if they were indi­vid­ual objects.

Using the Com­pos­ite pat­tern makes sense only when the core model of your app can be rep­re­sent­ed as a tree.

For exam­ple, imag­ine that you have two types of objects: Products and Boxes. A Box can con­tain sev­er­al Products as well as a num­ber of small­er Boxes. These lit­tle Boxes can also hold some Products or even small­er Boxes, and so on.

@St0iK
St0iK / app-composer.json
Created March 29, 2018 23:14
Composer Path Package - Building Symfony Bundle locally
"repositories": [
{
"type": "path",
"url": "/../../LoremIpsumBundle"
}
]
@St0iK
St0iK / gist:72398539de0809c5c64975ce4bede603
Created February 8, 2018 14:26 — forked from arnolanglade/gist:4ca0bedbcf41356a112a
PhpSpec Symfony command template
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class CommandSpec extends ObjectBehavior
{
function it_has_a_name()
{
$this->getName()->shouldReturn('name:command');
}
@St0iK
St0iK / rabbitmq.txt
Created July 14, 2017 09:16 — forked from sdieunidou/rabbitmq.txt
create admin user on rabbitmq
rabbitmqctl add_user test test
rabbitmqctl set_user_tags test administrator
rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
checks:
php: true
javascript: true
coding_style:
php:
spaces:
before_parentheses:
if: false
for: false
@St0iK
St0iK / FooController.php
Created April 17, 2017 11:33 — forked from weaverryan/FooController.php
Autowiring controller args
<?php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Psr\Log\LoggerInterface;
/**
* This class is now a service, so you can use normal __construct DI if you want!
*/
@St0iK
St0iK / FormErrorsSerializer.php
Created March 15, 2017 23:08 — forked from Graceas/FormErrorsSerializer.php
Symfony 2 Form Error Serializer. May be used for AJAX form validation. Allows tree and flat array styles for errors.
class FormErrorsSerializer {
public function serializeFormErrors(\Symfony\Component\Form\Form $form, $flat_array = false, $add_form_name = false, $glue_keys = '_')
{
$errors = array();
$errors['global'] = array();
$errors['fields'] = array();
foreach ($form->getErrors() as $error) {
$errors['global'][] = $error->getMessage();
$store = Mage::app()->getStore();
$rootId = Mage::app()->getStore($store->getId())->getRootCategoryId();
// $cat = Mage::getModel('catalog/category')->load(814);
try{
$layer = Mage::getModel("catalog/layer");
$category = Mage::getModel("catalog/category")->load(1183); // 3rd Category
$layer->setCurrentCategory($category);
$attributes = $layer->getFilterableAttributes();
<?php
namespace Creode\Deliveryday\Model;
use Magento\Checkout\Model\ConfigProviderInterface;
use Magento\Store\Model\ScopeInterface;
class DeliverydayConfigProvider implements ConfigProviderInterface
{
const XPATH_ENABLE_COMMENT_FIELD = 'creode_deliveryday/general/enable_comment_field';
const XPATH_DESCRIPTION = 'creode_deliveryday/general/description';
<style scoped="">
.on-the-fly-behavior {
position:relative;min-height:1020px;
}
.on-the-fly-behavior iframe{
top: 421px;
}
@media (max-width: 640px) {
.on-the-fly-behavior {