PHP code example of arthem / object-reference-bundle

1. Go to this page and download the library: Download arthem/object-reference-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

arthem / object-reference-bundle example snippets


namespace App\Entity;

use Arthem\ObjectReferenceBundle\Mapping\Attribute\ObjectReference;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;


#[ORM\Entity]
class Story
{
    #[ORM\Column(type: Types::STRING, length: 36, nullable: true)] 
    #[ObjectReference(keyLength: 15)] 
    private \Closure|Actor $actor;
    private $actorId; // must be declared, even if not used
    private $actorType; // must be declared, even if not used

    /**
     * @return object|null
     */
    public function getActor(): ?Actor
    {
        if ($this->actor instanceof \Closure) {
            $this->actor = $this->actor->call($this);
        }

        return $this->actor;
    }

    public function setActor(?Actor $actor)
    {
        $this->actor = $actor;
    }
}