PHP code example of zf3belcebur / doctrine-orm-resources
1. Go to this page and download the library: Download zf3belcebur/doctrine-orm-resources 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/ */
zf3belcebur / doctrine-orm-resources example snippets
return [
'doctrine' => [
'configuration' => [
'orm_default' => [
'class_metadata_factory_name' => ClassMetadataFactory::class,
'repository_factory' => BaseRepository::class,
]
]
];
return [
'doctrine' => [
'eventmanager' => [
'orm_default' => [
'subscribers' => [
TranslatableListener::class,
TimestampableListener::class,
SortableListener::class,
],
],
],
],
];
/**
* CustomRepo
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class CustomRepo extends BaseEntityRepository implements PostConstructInterface
{
use \ZF3Belcebur\DoctrineORMResources\RepositoryTrait\SortableListenerAdapterTrait;
public function postConstruct(): void
{
$this->initListenerConfig();
}
}
// Entity --> Application\Entity\Admin1
echo $admin1Repo->getEntityAlias(); // --> "a"
public function getQueryWithGedmoTranslation(QueryBuilder $qb, string $locale = null, string $defaultLocale = null): Query
public function findByQb(array $criteria, array $orderBy = [], int $limit = null, int $offset = null, string $alias = null): QueryBuilder;
$admin1sQb = $admin1Repo->findByQb(['country' => $country], ['name' => 'ASC']);
$criteria =
[
'orX' => [
[
'operator' => 'like',
'value' => '%espa%',
'field' => 'name',
],
[
'operator' => 'like',
'value' => '%espa%',
'field' => 'slugName',
],
'andX' => [
[
'operator' => 'eq',
'value' => '%espa%',
'field' => 'name',
],
[
'operator' => 'isNull',
'field' => 'slugName',
],
],
],
[
'operator' => 'like',
'value' => '%cosas%',
'field' => 'slug',
],
];
$admin1sQb = $admin1Repo->findByQb($criteria);
return [
__NAMESPACE__ => [
'gedmo' => [
'custom_translation_classes' => [
// 'YourNameSpace\CustomEntityTranslation1',
// 'YourNameSpace\CustomEntityTranslation2',
// 'YourNameSpace\CustomEntityTranslation3',
]
]
],
'doctrine' => [
'configuration' => [
'orm_default' => [
'class_metadata_factory_name' => ClassMetadataFactory::class,
]
]
]
];
namespace ZF3Belcebur\DoctrineORMResources;
return [
__NAMESPACE__ => [
'gedmo' => [
'custom_translation_classes' => [
// 'YourNameSpace\CustomEntityTranslation'
]
]
],
'service_manager' => [
'factories' => [
BaseRepository::class => BaseRepositoryFactory::class,
],
],
'doctrine' => [
'eventmanager' => [
'orm_default' => [
'subscribers' => [
TranslatableListener::class,
TimestampableListener::class,
//SortableListener::class,
],
],
],
'driver' => [
'translatable_orm_metadata_driver' => [
'class' => AnnotationORMDriver::class,
'cache' => 'array',
'paths' => [
getcwd() . '/vendor/gedmo/doctrine-extensions/src/Translatable/Entity',
],
],
'orm_default' => [
'drivers' => [
'Gedmo\Translatable\Entity' => 'translatable_orm_metadata_driver',
],
],
],
'configuration' => [
'orm_default' => [
'class_metadata_factory_name' => ClassMetadataFactory::class,
'repository_factory' => BaseRepository::class,
'types' => [
'point' => PointType::class,
'carbondate' => CarbonDateType::class,
'carbontime' => CarbonTimeType::class,
'linestring' => LineStringType::class,
'polygon' => PolygonType::class,
'multipolygon' => MultiPolygonType::class,
],
'datetime_functions' => [
'date' => Date::class,
'date_format' => DateFormat::class,
'dateadd' => DateAdd::class,
'datediff' => DateDiff::class,
'day' => Day::class,
'dayname' => DayName::class,
'last_day' => LastDay::class,
'minute' => Minute::class,
'second' => Second::class,
'strtodate' => StrToDate::class,
'time' => Time::class,
'timestampadd' => TimestampAdd::class,
'timestampdiff' => TimestampDiff::class,
'week' => Week::class,
'weekday' => WeekDay::class,
'year' => Year::class,
],
'numeric_functions' => [
'acos' => Acos::class,
'asin' => Asin::class,
'atan2' => Atan2::class,
'atan' => Atan::class,
'cos' => Cos::class,
'cot' => Cot::class,
'hour' => Hour::class,
'pi' => Pi::class,
'power' => Power::class,
'quarter' => Quarter::class,
'rand' => Rand::class,
'round' => Round::class,
'sin' => Sin::class,
'std' => Std::class,
'tan' => Tan::class,
'st_contains' => STContains::class,
'contains' => Contains::class,
'st_area' => Area::class,
STDistanceSphere::FUNCTION_NAME => STDistanceSphere::class,
'ST_Distance' => STDistance::class,
'GeomFromText' => GeomFromText::class,
'st_intersects' => STIntersects::class,
'st_buffer' => STBuffer::class,
'Point' => Point::class,
'GLength' => GLength::class,
'LineString' => LineString::class,
'LineStringFromWKB' => LineStringFromWKB::class,
],
'string_functions' => [
'binary' => Binary::class,
'char_length' => CharLength::class,
'concat_ws' => ConcatWs::class,
'countif' => CountIf::class,
'crc32' => Crc32::class,
'degrees' => Degrees::class,
'field' => Field::class,
'find_in_set' => FindInSet::class,
'group_concat' => GroupConcat::class,
'ifelse' => IfElse::class,
'ifnull' => IfNull::class,
'match_against' => MatchAgainst::class,
'md5' => Md5::class,
'month' => Month::class,
'monthname' => MonthName::class,
'nullif' => NullIf::class,
'radians' => Radians::class,
'regexp' => Regexp::class,
'replace' => Replace::class,
'sha1' => Sha1::class,
'sha2' => Sha2::class,
'soundex' => Soundex::class,
'uuid_short' => UuidShort::class,
],
],
],
],
];