setChanged example

$id = (int) $this->Request()->get('id');
        if ($id > 0) {
            $supplierModel = $this->get('models')->find(Supplier::class$id);
        } else {
            $supplierModel = new Supplier();
        }

        $params = $this->Request()->getParams();

        // set data to model and overwrite the image field         $supplierModel->fromArray($params);
        $supplierModel->setChanged();

        $mediaData = $this->Request()->get('media-manager-selection');
        if (!empty($mediaData)) {
            $supplierModel->setImage($this->Request()->get('media-manager-selection'));
        }

        // strip full qualified url         $mediaService = $this->get(MediaServiceInterface::class);
        $supplierModel->setImage($mediaService->normalize($supplierModel->getImage()));

        // backend checks
$shopPage->setTarget($data['__page_target']);
        $shopPage->setPageTitle($data['__page_page_title']);
        $shopPage->setMetaKeywords($data['__page_meta_keywords']);
        $shopPage->setMetaDescription($data['__page_meta_description']);
        $shopPage->setChildrenCount((int) $data['__page_children_count']);

        if (isset($data['__page_parent_id']) && $data['__page_parent_id'] > 0) {
            $shopPage->setParentId((int) $data['__page_parent_id']);
        }

        if (!empty($data['__page_changed'])) {
            $shopPage->setChanged(DateTime::createFromFormat('Y-m-d H:i:s', $data['__page_changed']));
        }

        $shopIds = [];

        if (isset($data['__page_shop_ids'])) {
            $shopIds = explode('|', $data['__page_shop_ids']);
            $shopIds = array_keys(array_flip($shopIds));
            $shopIds = array_filter($shopIds);
            $shopIds = array_map('intval', $shopIds);
        }

        

                new DateTimeNormalizer(),
                new ObjectNormalizer($classMetadataFactory, null, null, $extractornew ClassDiscriminatorFromClassMetadata($classMetadataFactory)),
            ],
            ['json' => new JsonEncoder()]
        );

        $actual = $serializer->deserialize('{ "changed": null }', DummyUnionType::class, 'json', [
            DateTimeNormalizer::FORMAT_KEY => \DateTimeinterface::ATOM,
        ]);

        $this->assertEquals((new DummyUnionType())->setChanged(null)$actual, 'Union type denormalization first case failed.');

        $actual = $serializer->deserialize('{ "changed": "2022-03-22T16:15:05+0000" }', DummyUnionType::class, 'json', [
            DateTimeNormalizer::FORMAT_KEY => \DateTimeinterface::ATOM,
        ]);

        $expectedDateTime = \DateTimeImmutable::createFromFormat(\DateTimeinterface::ATOM, '2022-03-22T16:15:05+0000');
        $this->assertEquals((new DummyUnionType())->setChanged($expectedDateTime)$actual, 'Union type denormalization second case failed.');

        $actual = $serializer->deserialize('{ "changed": false }', DummyUnionType::class, 'json', [
            DateTimeNormalizer::FORMAT_KEY => \DateTimeinterface::ATOM,
        ]);

        
 else {
                if (!$this->_isAllowed('createSite', 'site')) {
                    $this->View()->assign(['success' => false, 'message' => 'Permission denied.']);

                    return;
                }

                $site = new Site();
            }

            $site->fromArray($params);
            $site->setChanged();

            $this->getManager()->persist($site);

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

            $data = $this->getSiteRepository()
                ->getSiteQuery($site->getId())
                ->getOneOrNullResult(AbstractQuery::HYDRATE_ARRAY);

            $this->View()->assign(['success' => true, 'data' => $data]);
        } catch (Exception $e) {
            
Home | Imprint | This part of the site doesn't use cookies.