@param ItemEntity $item

@return ItemEntity[]
350435
public function findDuplicate(ItemEntity $item)
    {
        // get all names
        $names = [$item->getName()];
        foreach ($item->getNames() as $name) {
            $names[] = $name->getName();
        }

        // find from item main name
        $duplicate = $this->getEntityManager()->createQuery('
            SELECT
                i
            FROM
                AnimeDbCatalogBundle:Item i
            WHERE
                i.name IN (:names)
        ')
            ->setParameter(':names', $names)
            ->getResult();

        // find frim item other names
        $item_names = $this->getEntityManager()->createQuery('
            SELECT
                n
            FROM
                AnimeDbCatalogBundle:Name n
            WHERE
                n.name IN (:names)
            GROUP BY
                n.item
        ')
            ->setParameter(':names', $names)
            ->getResult();

        foreach ($item_names as $item_name) {
            // element has been added
            foreach ($duplicate as $item) {
                if ($item === $item_name->getItem()) {
                    continue 2;
                }
            }
            $duplicate[] = $item_name->getItem();
        }

        return $duplicate;
    }
64893
private function parseArrayToCatalogFieldEntities(array $items)
    {
        $entities = [];
        foreach ($items as $elementType => $catalogItems) {
            $entities = array_merge($entities, $this->parseArrayToFieldEntities($catalogItems, $elementType));
        }
        return $entities;
    }
1276120
public function setItem(Item $item)
    {
        $this->childOf = $item->id;
        $this->_item = $item;
        
        return $this;
    }
1315899
protected function getInfo(ItemEntity $item)
    {
        $filename = self::INFO_FILENAME.'.html';
        if (is_file($item->getPath())) {
            return dirname($item->getPath()).pathinfo($item->getPath(), PATHINFO_FILENAME).'-'.$filename;
        } else {
            return $item->getPath().'/'.$filename;
        }
    }
1035633
protected function getMenuItem(EntityInterface $menu, array $item, int $order = 0): array
    {
        if (empty($item)) {
            return [];
        }

        $label = $item['label'];
        $icon = $item['icon'];
        $type = $item['type'];

        $children = !empty($item['children']) ? $item['children'] : [];

        if (!empty($children)) {
            $count = 0;
            foreach ($children as $key => $child) {
                $children[$key] = $this->getMenuItem($menu, $child, ++$count);
            }
        }

        if (static::TYPE_MODULE === $type) {
            $item = $this->getMenuItemsFromEvent($menu->get('name'), [$item['url']]);
            reset($item);
            $item = current($item);
        }

        if (!empty($children)) {
            $item['children'] = $children;
        }

        if (empty($item)) {
            return [];
        }

        if (static::TYPE_MODULE === $type) {
            $item['label'] = $label;
            $item['icon'] = $icon;
        }

        $item['order'] = $order;

        return $item;
    }
500953
public function getWidgetItem(array $item) {
        $entity = new ItemWidget();

        $entity->setName($this->getItemName($item));
        $entity->setLink($this->browser->getHost().$item['url']);
        $entity->setCover($this->browser->getHost().$item['image']['original']);

        $catalog_item = $this->getCatalogItem($item);
        if ($catalog_item instanceof Item) {
            $entity->setItem($catalog_item);
        } elseif ($this->filler instanceof Filler) {
            $entity->setLinkForFill($this->filler->getLinkForFill($entity->getLink()));
        }

        return $entity;
    }
181554
protected function findOrCreateItem(array $item)
    {
        $object = null;
        // If the table was not truncated to begin with, find current object
        // first
        if (!$this->truncate) {
            if (!empty($this->lookupFields)) {
                $lookupConditions = array();
                foreach ($this->lookupFields as $fieldName) {
                    $lookupConditions[$fieldName] = $item[$fieldName];
                }

                $object = call_user_func($this->lookupMethod, $lookupConditions);
            } else {
                $object = $this->objectRepository->find(current($item));
            }
        }

        if (!$object) {
            return $this->getNewInstance();
        }

        return $object;
    }
487665
public function addItem($item)
    {
        if (!$this->getItems()) {
            return $this->setItems(array($item));
        } else {
            return $this->setItems(
                array_merge($this->getItems(), array($item))
            );
        }
    }
1129519
public function get($item)
    {
        $key = $this->getItemKey($item);

        if (null !== $key) {
            if (isset($this->items[$key])) {
                $item = $this->items[$key];
            } else {
                $this->items[$key] = $item;
            }
        }

        return $item;
    }
1011214
protected function validate(array $item)
    {
        $object = $this->objectFactory->factor($item);
        $list = $this->validator->validate($object);

        return $list;
    }
1321855
private function _shift(& $item) : array
    {
        $values = $this->getValues();
        if (empty($values)) {
            $item = null;
            return $values;
        }
        $item = array_shift($values);
        return $values;
    }
606411
protected function loadAssociationObjectsToEntity(array $item, $entity)
    {
        foreach ($this->entityMetadata->getAssociationMappings() as $associationMapping) {

            $value = null;
            if (isset($item[$associationMapping['fieldName']]) && !is_object($item[$associationMapping['fieldName']])) {
                $value = $this->entityManager->getReference($associationMapping['targetEntity'], $item[$associationMapping['fieldName']]);
            }

            if (null === $value) {
                continue;
            }

            $setter = 'set' . ucfirst($associationMapping['fieldName']);
            $this->setValue($entity, $value, $setter);
        }
    }
1203840
public function addItem(ItemInterface $item)
    {
        $this->itemsChanged = true;
        $this->entity->addItem($item);

        return $this;
    }
1173332
protected function prepareItem($item)
    {
        if (!isset($item["type"])) {
            return $item;
        }

        if (isset($item["children"])) {
            $item["children"] = $this->prepareItems($item["children"]);
        }

        switch ($item['type']) {
            case 'select':
                if (isset($item['sql'])) {
                    $connectionName = isset($item['connection']) ? $item['connection'] : 'default';
                    $sql            = $item['sql'];
                    $options        = isset($item["options"]) ? $item["options"] : array();

                    unset($item['sql']);
                    unset($item['connection']);
                    /** @var Connection $connection */
                    $connection = $this->container->get("doctrine.dbal.{$connectionName}_connection");
                    $all        = $connection->fetchAll($sql);
                    foreach ($all as $option) {
                        $options[] = array(reset($option), end($option));
                    }
                    $item["options"] = $options;
                }

                if (isset($item['service'])) {
                    $serviceInfo = $item['service'];
                    $serviceName = isset($serviceInfo['serviceName']) ? $serviceInfo['serviceName'] : 'default';
                    $method      = isset($serviceInfo['method']) ? $serviceInfo['method'] : 'get';
                    $args        = isset($serviceInfo['args']) ? $item['args'] : '';
                    $service     = $this->container->get($serviceName);
                    $options     = $service->$method($args);

                    $item['options'] = $options;
                }

                if (isset($item['dataStore'])) {
                    $dataStoreInfo = $item['dataStore'];
                    $dataStore     = $this->container->get('data.source')->get($dataStoreInfo["id"]);
                    $options       = array();
                    foreach ($dataStore->search() as $dataItem) {
                        $options[ $dataItem->getId() ] = $dataItem->getAttribute($dataStoreInfo["text"]);
                    }
                    if (isset($item['dataStore']['popupItems'])) {
                        $item['dataStore']['popupItems'] = $this->prepareItems($item['dataStore']['popupItems']);
                    }
                    $item['options'] = $options;
                }
                break;
        }
        return $item;
    }
321036
private function lookupRecursive($item)
    {
        if (is_array($item)) {
            $collection = [];
            foreach ($item as $k => $v) {
                $collection[$k] = $this->lookupRecursive($v);
            }

            return $collection;
        }

        return $this->lookup($item);
    }
1239738
public function parse(array $item): array
    {
        $siteSettings = [];
        foreach ($item['siteSettings'] as $settingKey => $settings) {
            $siteId = isset($settings['siteId']) ? Craft::$app->sites->getSiteByHandle($settings['siteId'])->id : Craft::$app->sites->getPrimarySite()->id;
            unset($settings['siteId']);
            $siteSettings[$siteId] = new CategoryGroup_SiteSettings(array_merge($settings, [
                'siteId' => $siteId,
                'hasUrls' => !empty($settings['uriFormat']),
            ]));
        }
        $categoryGroup = new CategoryGroup([
            'name' => $item['name'],
            'handle' => $item['handle'],
            'maxLevels' => $item['maxLevels'],
        ]);

        $categoryGroup->setSiteSettings($siteSettings);

        return [$categoryGroup, null];
    }
500006
public function getEntityHashes()
    {
        return array_map(function ($entity) {
            $class = get_class($entity);

            $mapper = Manager::getMapper($class);

            $keyName = $mapper->getEntityMap()->getKeyName();

            return $class.'.'.$entity->getEntityAttribute($keyName);
        },
        $this->items);
    }