пятница, 26 апреля 2019 г.

[Gitlab] how to edit gitlab-runner tags

Simply go to CI / CD > runner on Gitlab website, focus on your needed runner, press on modify icon and at the opened page modify runner tags.

It shouldn't be done from runner's machine, only at Gitlab.

четверг, 25 апреля 2019 г.

[Sylius] The page you are looking for does not exist. at /payment/capture/Nvh8PX4pKVmoPE3xLd-AkXdtebcn_onUdnHiXX1KT-8

It occurs when order is created with non-default locale, and at Payum method locale is reset, because route /payment/capture/{token} doesn't contains locale code placeholder.

You can fix it with adding to payum.xml route config /{locale} prefix in another route file, for example shop.yaml file.

[Sylius] fix mysql errors with INSERT INTO sylius_shipping_method_translation after services.yaml locale changing

If you have errors similar to INSERT INTO sylius_shipping_method_translation (name, description, locale, translatable_id) VALUES (?, ?, ?, ?)' with params [null, null, "lv", 1] error after services.yaml changing locale , also with another Sylius tables, try to manually add these records in database.

For example, if you have problems with product db table, go to admin/products/{id}/edit and add translation to your main locale, do it for every product.

It occurs when you switch the main locale, then adding something to cart (in another words create an order). Order entity has relation to Shipping method, which has relation to Shipping method translation entity, which doesn't exists with needed locale. So Doctrine thinks it should persist before creating an Order, so there occurs an error.

среда, 17 апреля 2019 г.

Another way to create Sylius Resource factory

Use this in services.yaml:

App\Factory\RideFactory:
        decorates: app.factory.ride
        arguments:
            - "@App\Factory\RideFactory.inner"


App\Factory\RideFactory:
<?php
declare(strict_types=1);

namespace App\Factory;

use App\Entity\Ride;
use Sylius\Component\Resource\Factory\FactoryInterface;

class RideFactory implements FactoryInterface
{
    /**
     * @var FactoryInterface
     */
    private $decorated;

    public function __construct(FactoryInterface $decoratedFactory)
    {
        $this->decorated = $decoratedFactory;
    }

    public function createNew()
    {
        return new Ride();
    }
}

Finally you shouldn't add anything into `sylius_resource` in config.yml.

пятница, 12 апреля 2019 г.

[PHP] Docker doesn't applies code changes in container!

Be sure your php.ini doesn't have opcache.validate_timestamps=0. Actually there is no issues with Docker, only OPcache.

суббота, 6 апреля 2019 г.

[Sylius] How to autowire AbstractResourceType

Use this in your class:

final class HomepageOrderType extends AbstractResourceType
{
    public function __construct(array $validationGroups = [])
    {
        parent::__construct(Order::class, $validationGroups);
    }
    ...