src/Creation/ImageItemFactory.php
public function createCrop(BType $cropType, array $data, $cap = false)
    {
        if($cropType->getName() !== 'crop')
        {
            throw new ImageAggrException('Попытка создания кропа с типом не равным crop ('.$cropType->getName().')!');
        }

        $fields  = $this->collectionFactory->createFieldsCollection();
        $owns    = $this->collectionFactory->createOwnsCollection();
        $refs    = $this->collectionFactory->createRefsCollection();

        $cropItem = new CropItem($cropType, $fields, $owns, $refs, $cap);

        $metaName       = $cropType->getOwn('name');
        $metaLink       = $cropType->getOwn('link');
        $metaAlt        = $cropType->getOwn('alt');
        $metaCacheIndex = $cropType->getOwn('cache_index');
        $metaWidth      = $cropType->getOwn('width');
        $metaHeight     = $cropType->getOwn('height');
        $metaX          = $cropType->getOwn('x');
        $metaY          = $cropType->getOwn('y');

        $metaOriginal   = $cropType->getRef('original');
        $metaMan        = $cropType->getRef('man');
        $metaTarget     = $cropType->getRef('target');

        $fieldName       = $this->createLocalCField($cropItem, $metaName,       $this->checkAndGetData($data, 'name', 'string'));
        $fieldLink       = $this->createLocalCField($cropItem, $metaLink,       $this->checkAndGetData($data, 'link', 'string'));
        $fieldAlt        = $this->createLocalCField($cropItem, $metaAlt,        $this->checkAndGetData($data, 'alt', 'string'));
        $fieldCacheIndex = $this->createLocalCField($cropItem, $metaCacheIndex, $this->checkAndGetData($data, 'cache_index', 'integer'));
        $fieldWidth      = $this->createLocalCField($cropItem, $metaWidth,      $this->checkAndGetData($data, 'width', 'integer'));
        $fieldHeight     = $this->createLocalCField($cropItem, $metaHeight,     $this->checkAndGetData($data, 'height', 'integer'));
        $fieldX          = $this->createLocalCField($cropItem, $metaX,          $this->checkAndGetData($data, 'x', 'integer'));
        $fieldY          = $this->createLocalCField($cropItem, $metaY,          $this->checkAndGetData($data, 'y', 'integer'));

        //Собственные поля
        $cropItem->setOwn($fieldName);  $cropItem->setField($fieldName);
        $cropItem->setOwn($fieldLink);  $cropItem->setField($fieldLink);
        $cropItem->setOwn($fieldAlt);   $cropItem->setField($fieldAlt);
        $cropItem->setOwn($fieldCacheIndex); $cropItem->setField($fieldCacheIndex);
        $cropItem->setOwn($fieldWidth);  $cropItem->setField($fieldWidth);
        $cropItem->setOwn($fieldHeight); $cropItem->setField($fieldHeight);
        $cropItem->setOwn($fieldX);      $cropItem->setField($fieldX);
        $cropItem->setOwn($fieldY);      $cropItem->setField($fieldY);

        //Ссылки
        $originalRef = new OriginalRefField($cropItem, $metaOriginal);
        $manRef      = new ResizeRefField($cropItem, $metaMan);
        $targetRef   = new ResizeRefField($cropItem, $metaTarget);

        $cropItem->setRef($originalRef); $cropItem->setField($originalRef);
        $cropItem->setRef($manRef);      $cropItem->setField($manRef);
        $cropItem->setRef($targetRef);   $cropItem->setField($targetRef);

        return $cropItem;
    }
public function createCrop(BType $cropType, array $data, $cap = false)
    {
        if($cropType->getName() !== 'crop')
        {
            throw new ImageAggrException('Попытка создания кропа с типом не равным crop ('.$cropType->getName().')!');
        }

        $fields  = $this->collectionFactory->createFieldsCollection();
        $owns    = $this->collectionFactory->createOwnsCollection();
        $refs    = $this->collectionFactory->createRefsCollection();

        $cropItem = new CropItem($cropType, $fields, $owns, $refs, $cap);

        $metaName       = $cropType->getOwn('name');
        $metaLink       = $cropType->getOwn('link');
        $metaAlt        = $cropType->getOwn('alt');
        $metaCacheIndex = $cropType->getOwn('cache_index');
        $metaWidth      = $cropType->getOwn('width');
        $metaHeight     = $cropType->getOwn('height');
        $metaX          = $cropType->getOwn('x');
        $metaY          = $cropType->getOwn('y');

        $metaOriginal   = $cropType->getRef('original');
        $metaMan        = $cropType->getRef('man');
        $metaTarget     = $cropType->getRef('target');

        $fieldName       = $this->createLocalCField($cropItem, $metaName,       $this->checkAndGetData($data, 'name', 'string'));
        $fieldLink       = $this->createLocalCField($cropItem, $metaLink,       $this->checkAndGetData($data, 'link', 'string'));
        $fieldAlt        = $this->createLocalCField($cropItem, $metaAlt,        $this->checkAndGetData($data, 'alt', 'string'));
        $fieldCacheIndex = $this->createLocalCField($cropItem, $metaCacheIndex, $this->checkAndGetData($data, 'cache_index', 'integer'));
        $fieldWidth      = $this->createLocalCField($cropItem, $metaWidth,      $this->checkAndGetData($data, 'width', 'integer'));
        $fieldHeight     = $this->createLocalCField($cropItem, $metaHeight,     $this->checkAndGetData($data, 'height', 'integer'));
        $fieldX          = $this->createLocalCField($cropItem, $metaX,          $this->checkAndGetData($data, 'x', 'integer'));
        $fieldY          = $this->createLocalCField($cropItem, $metaY,          $this->checkAndGetData($data, 'y', 'integer'));

        //Собственные поля
        $cropItem->setOwn($fieldName);  $cropItem->setField($fieldName);
        $cropItem->setOwn($fieldLink);  $cropItem->setField($fieldLink);
        $cropItem->setOwn($fieldAlt);   $cropItem->setField($fieldAlt);
        $cropItem->setOwn($fieldCacheIndex); $cropItem->setField($fieldCacheIndex);
        $cropItem->setOwn($fieldWidth);  $cropItem->setField($fieldWidth);
        $cropItem->setOwn($fieldHeight); $cropItem->setField($fieldHeight);
        $cropItem->setOwn($fieldX);      $cropItem->setField($fieldX);
        $cropItem->setOwn($fieldY);      $cropItem->setField($fieldY);

        //Ссылки
        $originalRef = new OriginalRefField($cropItem, $metaOriginal);
        $manRef      = new ResizeRefField($cropItem, $metaMan);
        $targetRef   = new ResizeRefField($cropItem, $metaTarget);

        $cropItem->setRef($originalRef); $cropItem->setField($originalRef);
        $cropItem->setRef($manRef);      $cropItem->setField($manRef);
        $cropItem->setRef($targetRef);   $cropItem->setField($targetRef);

        return $cropItem;
    }
@param \Interpro\Core\Contracts\Taxonomy\Types\BType $cropType
@param array $data
@param bool $cap

@return \Interpro\ImageAggr\Items\CropItem