src/Model/Sector.php line 8

Open in your IDE?
  1. <?php
  2. namespace App\Model;
  3. use App\Helpers\PageObjectRelationHelper;
  4. class Sector extends \Pimcore\Model\DataObject\Sector
  5. {
  6.     /**
  7.      * @return \Pimcore\Model\Document\Page|null
  8.      */
  9.     public function page()
  10.     {
  11.         return (new PageObjectRelationHelper())->getSectorPageFromSectorObject($this);
  12.     }
  13.     public function renderThumbnail($thumbnail "default"$options = [])
  14.     {
  15.         $image $this->getVisuals()?->getItems()[0] ?? null;
  16.         return $image?->getImage()?->getThumbnail($thumbnail)->getHtml($options);
  17.     }
  18.     public function projects()
  19.     {
  20.         $def $this->getClass()->getFieldDefinition("projects");
  21.         $refKey $def->getOwnerFieldName();
  22.         $refId $def->getOwnerClassId();
  23.         $nonOwnerRelations $this->getRelationData($refKeyfalse$refId);
  24.         #yoinked: https://pimcore.com/docs/pimcore/10.2/Development_Documentation/Objects/Object_Classes/Data_Types/Reverse_Object_Relation_Type.html
  25.         foreach ($nonOwnerRelations as $relation){
  26.             $projects[] = Project::getById($relation['id']);
  27.         }
  28.         return $projects ?? false;
  29.     }
  30. }