Pimcore\Model\Document\Hardlink\Service::wrap PHP Method

wrap() public static method

public static wrap ( Document $doc ) : Document
$doc Pimcore\Model\Document
return Pimcore\Model\Document
    public static function wrap(Document $doc)
    {
        if ($doc instanceof Document\Hardlink) {
            if ($sourceDoc = $doc->getSourceDocument()) {
                $destDoc = self::upperCastDocument($sourceDoc);
                $destDoc->setKey($doc->getKey());
                $destDoc->setPath($doc->getRealPath());
                $destDoc->initDao(get_class($sourceDoc), true);
                $destDoc->setHardLinkSource($doc);
                return $destDoc;
            }
        } else {
            $sourceClass = get_class($doc);
            $doc = self::upperCastDocument($doc);
            $doc->initDao($sourceClass, true);
            return $doc;
        }
        return;
    }

Usage Example

Beispiel #1
0
 public function getChilds()
 {
     if ($this->childs === null) {
         $hardLink = $this->getHardLinkSource();
         $childs = array();
         if ($hardLink->getChildsFromSource() && $hardLink->getSourceDocument() && !\Pimcore::inAdmin()) {
             foreach (parent::getChilds() as $c) {
                 $sourceDocument = $c;
                 $c = Service::wrap($c);
                 if ($c) {
                     $c->setHardLinkSource($hardLink);
                     $c->setSourceDocument($sourceDocument);
                     $c->setPath(preg_replace("@^" . preg_quote($hardLink->getSourceDocument()->getRealFullpath()) . "@", $hardLink->getRealFullpath(), $c->getRealPath()));
                     $childs[] = $c;
                 }
             }
         }
         $this->setChilds($childs);
     }
     return $this->childs;
 }
All Usage Examples Of Pimcore\Model\Document\Hardlink\Service::wrap