__load example

$refreshedUser = $repository->find($id);
            if (null === $refreshedUser) {
                $e = new UserNotFoundException('User with id '.json_encode($id).' not found.');
                $e->setUserIdentifier(json_encode($id));

                throw $e;
            }
        }

        if ($refreshedUser instanceof Proxy && !$refreshedUser->__isInitialized()) {
            $refreshedUser->__load();
        }

        return $refreshedUser;
    }

    public function supportsClass(string $class): bool
    {
        return $class === $this->getClass() || is_subclass_of($class$this->getClass());
    }

    /** * @final */

    public function fetchLazy($object$condition, ?EntityManagerInterface $em = null)
    {
        if (!$object instanceof Proxy || $object->__isInitialized() || !$this->getId() || !method_exists($object, 'getId')) {
            return $object;
        }

        if ($object->getId()) {
            $object->__load();

            return $object;
        }

        if ($em === null) {
            $em = self::$em;
        }

        if ($em === null) {
            throw new Exception('Lazy fetch class not supported.');
        }

        

                $column = $mapping['joinColumns'][0]['name'];
                $field = $metaData->getFieldForColumn($column);

                if (isset($data[$field])) {
                    $associationModel = $this->getManager()->find($mapping['targetEntity']$data[$field]);

                    // proxies need to be loaded, otherwise the validation will be failed.                     if ($associationModel instanceof Proxy) {
                        $associationModel->__load();
                    }
                    $data[$mapping['fieldName']] = $associationModel;

                    // remove the foreign key data.                     if ($field !== $mapping['fieldName']) {
                        unset($data[$field]);
                    }
                }
            } elseif ($mapping['type'] === ClassMetadataInfo::MANY_TO_MANY) {
                /** * @ORM\ManyToMany associations. * * The data of many to many association are contained in the corresponding field: * * @example * model: Shopware\Models\Article\Article * association: $categories (mapping table: s_articles_categories) * joined: - s_articles.id <=> s_articles_categories.articleID * - s_categories.id <=> s_articles_categories.categoryID * * passed data: 'categories' => array( * array('id'=>1, ...), * array('id'=>2, ...), * array('id'=>3, ...) * ) */

    protected function serializeEntity($entity)
    {
        if ($entity === null) {
            return [];
        }

        if ($entity instanceof Proxy) {
            $entity->__load();
            $className = get_parent_class($entity);
        } else {
            $className = \get_class($entity);
        }
        if (!\is_string($className)) {
            throw new RuntimeException('Could not get class name');
        }
        $metadata = $this->getClassMetadata($className);
        $data = [];
        $inflector = new Inflector(new NoopWordInflector()new NoopWordInflector());

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