Skip to content

Instantly share code, notes, and snippets.

View erop's full-sized avatar

Egor Ushakov erop

View GitHub Profile
@erop
erop / gist:935573
Created April 21, 2011 21:55 — forked from jmertic/gist:825943
PHP: Check if SugarCRM record is new
<?php
if (!empty($bean->fetched_row['id'])) {
// Do custom logic
}
<?php
// this file is upgrade safe
// location: custom/modules/Contacts/views/view.detail.php
require_once('modules/Contacts/views/view.detail.php');
class CustomContactsViewDetail extends ContactsViewDetail {
/**
* @see SugarView::display()
@erop
erop / AbstractObject.php
Last active August 8, 2017 07:40
How to let PhpStorm to know more about my static methods?
<?php
abstract class AbstractObject
{
// we use static var to enforce setting up entry point
// in child classes
public static $entryPoint = null;
public static function getEntryPoint()
florianv_swap:
cache:
type: psr16_cache_apcu
ttl: 86400
@erop
erop / services.xml
Created March 23, 2020 11:15
Try to setup scoped HttpClient in services.xml
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xmlns="http://symfony.com/schema/dic/services"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<services>
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use MyVendor\Contracts\Entity\VehicleInterface;
use MyVendor\Contracts\Entity\VehicleOwnerInterface;
<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
// REQUEST
{
"year":2017,
"vin":"134513879",
"plate":"A123AA777",
"powerHp":"146.1",
"model":"/api/vehicle_models/000b69fa-a335-49d6-b7be-49fbe570376a",
"ownerPerson": {
"firstName":"Egor"
}
@erop
erop / example.json
Created July 7, 2020 19:12
DiscriminatorMap example
{
"type": "Person",
"firstName": "Ivan",
"lastName": "Ivanov"
}
{
"type": "Company",
"name": "ACME Consulting",
"city": "Moscow"
}
<?php
declare(strict_types=1);
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\Entity;
/**
* @Entity