getMetadataFactory example


        if (null === $name) {
            return $this->registry->getManagerForClass($class);
        }

        try {
            $manager = $this->registry->getManager($name);
        } catch (\InvalidArgumentException) {
            return null;
        }

        return $manager->getMetadataFactory()->isTransient($class) ? null : $manager;
    }

    private function find(ObjectManager $manager, Request $request, MapEntity $options, string $name): false|object|null
    {
        if ($options->mapping || $options->exclude) {
            return false;
        }

        $id = $this->getIdentifier($request$options$name);
        if (false === $id || null === $id) {
            return $id;
        }

        if (!\is_object($value) || $value instanceof \DateTimeInterface) {
            return $this->formatValue($value, self::PRETTY_DATE);
        }

        if ($value instanceof \Stringable) {
            return (string) $value;
        }

        if ($class->getName() !== $idClass = $value::class) {
            // non unique value might be a composite PK that consists of other entity objects             if ($em->getMetadataFactory()->hasMetadataFor($idClass)) {
                $identifiers = $em->getClassMetadata($idClass)->getIdentifierValues($value);
            } else {
                // this case might happen if the non unique column has a custom doctrine type and its value is an object                 // in which case we cannot get any identifiers for it                 $identifiers = [];
            }
        } else {
            $identifiers = $class->getIdentifierValues($value);
        }

        if (!$identifiers) {
            
/** * Initializes a new <tt>BasicEntityPersister</tt> that uses the given EntityManager * and persists instances of the class described by the given ClassMetadata descriptor. */
    public function __construct(EntityManagerInterface $em, ClassMetadata $class)
    {
        $this->em                    = $em;
        $this->class                 = $class;
        $this->conn                  = $em->getConnection();
        $this->platform              = $this->conn->getDatabasePlatform();
        $this->quoteStrategy         = $em->getConfiguration()->getQuoteStrategy();
        $this->identifierFlattener   = new IdentifierFlattener($em->getUnitOfWork()$em->getMetadataFactory());
        $this->noLimitsContext       = $this->currentPersisterContext = new CachedPersisterContext(
            $class,
            new Query\ResultSetMapping(),
            false
        );
        $this->limitsHandlingContext = new CachedPersisterContext(
            $class,
            new Query\ResultSetMapping(),
            true
        );
    }

    

    public function regenerateAttributeProxies($tableNames = [])
    {
        $metaDataCache = $this->getConfiguration()->getMetadataCacheImpl();

        if ($metaDataCache !== null && method_exists($metaDataCache, 'deleteAll')) {
            $metaDataCache->deleteAll();
        }

        $allMetaData = $this->getMetadataFactory()->getAllMetadata();
        $proxyFactory = $this->getProxyFactory();

        $attributeMetaData = [];
        foreach ($allMetaData as $metaData) {
            if (!$metaData instanceof ClassMetadata) {
                continue;
            }

            $tableName = $metaData->getTableName();
            if (!str_contains($tableName, '_attributes')) {
                continue;
            }
throw new \RuntimeException(sprintf('Unable to create the Doctrine Proxy directory "%s".', $proxyCacheDir));
                }
            } elseif (!is_writable($proxyCacheDir)) {
                throw new \RuntimeException(sprintf('The Doctrine Proxy directory "%s" is not writeable for the current system user.', $proxyCacheDir));
            }

            // if proxies are autogenerated we don't need to generate them in the cache warmer             if ($em->getConfiguration()->getAutoGenerateProxyClasses()) {
                continue;
            }

            $classes = $em->getMetadataFactory()->getAllMetadata();

            $em->getProxyFactory()->generateProxyClasses($classes);

            foreach (scandir($proxyCacheDir) as $file) {
                if (!is_dir($file = $proxyCacheDir.'/'.$file)) {
                    $files[] = $file;
                }
            }
        }

        return $files;
    }

        $this->checkPrivilege('create');

        $manufacturer = new ManufacturerModel();

        $params = $this->prepareManufacturerData($params);
        $params = $this->prepareMediaData($params$manufacturer);

        $manufacturer->fromArray($params);

        if (isset($params['id'])) {
            $metaData = $this->getManager()->getMetadataFactory()->getMetadataFor(ManufacturerModel::class);
            $metaData->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
            $manufacturer->setPrimaryIdentifier($params['id']);
        }

        $violations = $this->getManager()->validate($manufacturer);
        if ($violations->count() > 0) {
            throw new ValidationException($violations);
        }

        $this->getManager()->persist($manufacturer);
        $this->flush();

        
$this->checkPrivilege('create');

        $category = new CategoryModel();

        $params = $this->prepareCategoryData($params);
        $params = $this->prepareMediaData($params$category);
        $params = $this->prepareManualSorting($params$category);

        $category->fromArray($params);

        if (isset($params['id'])) {
            $metaData = $this->getManager()->getMetadataFactory()->getMetadataFor(CategoryModel::class);
            $metaData->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE);
            $category->setPrimaryIdentifier($params['id']);
        }

        $violations = $this->getManager()->validate($category);
        if ($violations->count() > 0) {
            throw new ValidationException($violations);
        }

        $this->getManager()->persist($category);
        $this->flush();

        
Home | Imprint | This part of the site doesn't use cookies.