1. Go to this page and download the library: Download fsi/metadata 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/ */
fsi / metadata example snippets
namespace FSi\Bundle\SiteBundle\Metadata\Driver;
use FSi\Component\Metadata\ClassMetadataInterface;
use FSi\Component\Metadata\Driver\AbstractAnnotationDriver;
class AnnotationDriver extends AbstractAnnotationDriver
{
public function loadClassMetadata(ClassMetadataInterface $metadata)
{
$classReflection = $metadata->getClassReflection();
$className = $classReflection->getName();
$classReflectionProperties = $classReflection->getProperties();
foreach ($classReflectionProperties as $property) {
if ($property->getDeclaringClass()->getName() == $className) {
foreach ($this->getAnnotationReader()->getPropertyAnnotations($property) as $element) {
$metadata->addPropertyMetadata($property->name, $element->name, $element->value);
}
}
}
}
}
namespace FSi\Bundle\SiteBundle\Metadata\Mapping\Annotation;
use Doctrine\Common\Annotations\Annotation;
/** @Annotation */
final class Field extends Annotation {
public $name;
public $value;
}
public function metadataAction()
{
$driver = new \FSi\Bundle\SiteBundle\Metadata\Driver\AnnotationDriver($this->get('annotation_reader'));
$factory = new MetadataFactory($driver);
$metdata = $factory->getClassMetadata('FSi\Bundle\SiteBundle\Entity\MetaTest');
}
public function metadataAction()
{
$cache = new Doctrine\Common\Cache\ApcCache();
$driver = new \FSi\Bundle\SiteBundle\Metadata\Driver\AnnotationDriver($this->get('annotation_reader'));
// the third parameter should be used when one cache instance will be used in many metadata factories.
$factory = new MetadataFactory($driver, $cache, 'cache-prefix');
$metdata = $factory->getClassMetadata('FSi\Bundle\SiteBundle\Entity\MetaTest');
}
$factory = new MetadataFactory($driver, $cache, 'cache-namespace', 'FSi\SiteBundle\Metadata\MyClassMetadata');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.