Skip to content

Instantly share code, notes, and snippets.

@dnahrebecki
dnahrebecki / SwitchPhpCommand.php
Created February 17, 2022 09:44
Command for switching PHP versions [tested in Ubuntu only]
<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@dnahrebecki
dnahrebecki / EstimateClocCommand.php
Created February 16, 2022 13:39
Command for generating LOC statistics for a Symfony project
<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@dnahrebecki
dnahrebecki / AbstractQueryConverter.php
Last active September 15, 2017 07:42
Workaround for supporting virtual fields in virtual relations
<?php
namespace Oro\Bundle\QueryDesignerBundle\QueryDesigner;
abstract class AbstractQueryConverter
{
// ....
// Please add this new method (added new one due to BC. In master probably addTableAliasesForVirtualField will be refactored instead.)
@dnahrebecki
dnahrebecki / ContactEmailChangeProcessor.php
Created September 13, 2017 09:20
Message Processor which listen to Contact's email changes and call API
<?php
namespace ClientCustomBundle\Async;
use Oro\Component\MessageQueue\Client\TopicSubscriberInterface;
use Oro\Component\MessageQueue\Consumption\MessageProcessorInterface;
use Oro\Component\MessageQueue\Transport\MessageInterface;
use Oro\Component\MessageQueue\Transport\SessionInterface;
use Oro\Bundle\DataAuditBundle\Async\Topics;
<?php
namespace Oro\Bundle\CustomerBundle\Api\Processor\Create;
use Oro\Bundle\CustomerBundle\Entity\CustomerUser;
use Oro\Bundle\CustomerBundle\Entity\CustomerUserManager;
use Oro\Component\ChainProcessor\ContextInterface;
use Oro\Component\ChainProcessor\ProcessorInterface;
use Oro\Bundle\ApiBundle\Processor\Create\CreateContext;
@dnahrebecki
dnahrebecki / billing_information.html.twig
Created May 9, 2017 08:48
[OroCommerce] Checkout without shipping
{% block _checkout_form_fields_widget -%}
{% from 'OroAddressBundle::macros.html.twig' import renderAddress %}
{% if workflowItem.data.get('disallow_billing_address_edit') %}
{% set billingAddress = checkout.billingAddress %}
<fieldset class="grid__row grid__row--offset-none">
<div class="grid__column grid__column--offset-y grid__column--6">
{{ renderAddress(checkout.billingAddress) }}
</div>
</fieldset>
{% else %}
@dnahrebecki
dnahrebecki / UserController.php
Created May 5, 2017 22:22
Query Extended Entities
<?php
// ****************** PLEASE READ *******************
// STR:
// 1. Create ExtendedEntity with field 'label'.
// 2. Add new field to User entity. Field name: "extend"
// 3. Update schema
// 4. Create 2 records in DB (table: oro_ext_extendedentity). 1;ex_label_1 and 2;ex_label_2
// 5. Go to System -> User management -> Users
// 6. Edit one of user and assign 'ex_label_1' to new field User::extend. Save record