PHP code example of timostamm / orm-resource
1. Go to this page and download the library: Download timostamm/orm-resource 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/ */
timostamm / orm-resource example snippets
/** @ORM\Entity() */
class TestEntity
{
/**
* @ORM\Embedded(class = EmbeddedResource::class )
*/
private $file;
public function getFile(): ?ResourceInterface
{
return $this->file;
}
public function setFile(?ResourceInterface $resource): void
{
$this->file = EmbeddedResource::create($resource);
}
}
$em->getEventManager()
->addEventSubscriber(new ORMResourceHandler(new HashStorage($storageDir)));
$e = new TestEntity();
$e->setFile(Resource::fromFile(__FILE__));
$em->persist($e);
$em->flush($e);