AbstractEntityAdapter

Abstract entity API adapter.
extends Omeka\Api\Adapter\AbstractAdapter implements Omeka\Api\Adapter\EntityAdapterInterface

Known subclasses

Omeka\Api\Adapter\AbstractResourceEntityAdapter, Omeka\Api\Adapter\AssetAdapter, Omeka\Api\Adapter\ItemAdapter, Omeka\Api\Adapter\ItemSetAdapter, Omeka\Api\Adapter\JobAdapter, Omeka\Api\Adapter\MediaAdapter, Omeka\Api\Adapter\PropertyAdapter, Omeka\Api\Adapter\ResourceAdapter, Omeka\Api\Adapter\ResourceClassAdapter, Omeka\Api\Adapter\ResourceTemplateAdapter, Omeka\Api\Adapter\SiteAdapter, Omeka\Api\Adapter\SitePageAdapter, Omeka\Api\Adapter\UserAdapter, Omeka\Api\Adapter\VocabularyAdapter
Abstract
Open source code
Methods Summary
abstract public
# hydrate( Omeka\Api\Request $request , Omeka\Entity\EntityInterface $entity , Omeka\Stdlib\ErrorStore $errorStore )
Hydrate an entity with the provided array. Validation should be done in {@link self::validateRequest()} or {@link self::validateEntity()}. Filtering should be done in the entity's mutator methods. Authorize state changes of individual fields using {@link self::authorize()}.
public
# validateRequest( Omeka\Api\Request $request , Omeka\Stdlib\ErrorStore $errorStore )
Validate entity data. This happens before entity hydration. Only use this for validations that don't require a hydrated entity, typically limited to validating for expected data format and internal consistency. Set validation errors to the passed $errorStore object. If an error is set the entity will not be hydrated, created, or updated.
public
# validateEntity( Omeka\Entity\EntityInterface $entity , Omeka\Stdlib\ErrorStore $errorStore )
Validate an entity. This happens after entity hydration. Use this method for validations that require a hydrated entity (i.e. most validations). Set validation errors to the passed $errorStore object. If an error is set the entity will not be created or updated.
public
# buildQuery( Doctrine\ORM\QueryBuilder $qb , array $query )
Build a conditional search query from an API request. Modify the passed query builder object according to the passed $query data. The sort_by, sort_order, page, limit, and offset parameters are included separately.

link

public
# sortQuery( Doctrine\ORM\QueryBuilder $qb , array $query )
Set sort_by and sort_order conditions to the query builder.
public
# sortByCount( Doctrine\ORM\QueryBuilder $qb , array $query , string $inverseField , string|null $instanceOf = NULL )
Sort a query by inverse association count.
public
# limitQuery( Doctrine\ORM\QueryBuilder $qb , array $query )
Set page, limit (max results) and offset (first result) conditions to the query builder.
public
public
# batchCreate( Omeka\Api\Request $request )
Batch create entities. Preserves the keys of the request content array as the keys of the response content array. This is helpful for implementations that need to map original identifiers to the newly created entity IDs. There are two outcomes if an exception is thrown during a batch. If continueOnError is set to the request, the current entity is thrown away but the operation continues. Otherwise, all previously persisted entities are detached from the entity manager. Detaches entities after they've been created to minimize memory usage. Because the entities are detached, this returns resource references (containing only the entity ID) instead of full entity representations. {@inheritDoc}

Overrides

public
public
public
public
public
public
# getEntityManager( )
Get the entity manager.
public
# deleteEntity( Omeka\Api\Request $request )
Delete an entity. Encapsulates finding, authorization, post-find event, and removal into one method.
public
# hydrateEntity( Omeka\Api\Request $request , Omeka\Entity\EntityInterface $entity , Omeka\Stdlib\ErrorStore $errorStore )
Hydrate an entity. Encapsulates hydration, authorization, pre-validation API events, and validation procedures into one method.
protected
# authorize( Omeka\Entity\EntityInterface $entity , string $privilege )
Verify that the current user has access to the entity.
public
# findEntity( mixed $criteria , \Request|null $request = NULL )
Find a single entity by criteria.
public
# createNamedParameter( Doctrine\ORM\QueryBuilder $qb , mixed $value , string $prefix = 'omeka_' )
Create a unique named parameter for the query builder and bind a value to it.
public
# createAlias( string $prefix = 'omeka_' )
Create a unique alias for the query builder.
public
# isTerm( string $term )
Determine whether a string is a valid JSON-LD term.
public
# isUnique( Omeka\Entity\EntityInterface $entity , array $criteria )
Check for uniqueness by a set of criteria.
public
# shouldHydrate( Omeka\Api\Request $request , string $key )
Check whether to hydrate on a key.
public
# hydrateOwner( Omeka\Api\Request $request , Omeka\Entity\EntityInterface $entity )
Hydrate the entity's owner. Assumes the owner can be set to NULL. By default, new entities are owned by the current user. This diverges from the conventional hydration pattern for an update operation. Normally the absence of [o:owner] would set the value to null. In this case [o:owner][o:id] must explicitly be set to null.
public
# hydrateResourceClass( Omeka\Api\Request $request , Omeka\Entity\EntityInterface $entity )
Hydrate the entity's resource class. Assumes the resource class can be set to NULL.
public
# hydrateResourceTemplate( Omeka\Api\Request $request , Omeka\Entity\EntityInterface $entity )
Hydrate the entity's resource template. Assumes the resource template can be set to NULL.
public
# updateTimestamps( Omeka\Api\Request $request , Omeka\Entity\EntityInterface $entity )
Update created/modified timestamps as appropriate for a request.
Methods inherited from Omeka\Api\Adapter\AbstractAdapter
getRepresentationClass(), search(), create(), batchCreate(), read(), update(), batchUpdate(), preprocessBatchUpdate(), delete(), batchDelete(), getAdapter(), getRepresentation(), getTranslator(), getResourceId(), setServiceLocator(), getServiceLocator()
Properties Summary
protected int $index
A unique token index for query builder aliases and placeholders.
# 0
protected array $sortFields
Entity fields on which to sort search results. The keys are the value of "sort_by" query. The values are the corresponding entity fields on which to sort.
# array ( )
Properties inherited from Omeka\Api\Adapter\AbstractAdapter
$translator, $serviceLocator