idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
3,600
|
public function withShortName ( string $ shortName ) : self { $ metadata = clone $ this ; $ metadata -> shortName = $ shortName ; return $ metadata ; }
|
Returns a new instance with the given short name .
|
3,601
|
public function withIri ( string $ iri ) : self { $ metadata = clone $ this ; $ metadata -> iri = $ iri ; return $ metadata ; }
|
Returns a new instance with the given IRI .
|
3,602
|
public function getCollectionOperationAttribute ( ? string $ operationName , string $ key , $ defaultValue = null , bool $ resourceFallback = false ) { return $ this -> findOperationAttribute ( $ this -> collectionOperations , $ operationName , $ key , $ defaultValue , $ resourceFallback ) ; }
|
Gets a collection operation attribute optionally fallback to a resource attribute .
|
3,603
|
public function getItemOperationAttribute ( ? string $ operationName , string $ key , $ defaultValue = null , bool $ resourceFallback = false ) { return $ this -> findOperationAttribute ( $ this -> itemOperations , $ operationName , $ key , $ defaultValue , $ resourceFallback ) ; }
|
Gets an item operation attribute optionally fallback to a resource attribute .
|
3,604
|
public function getSubresourceOperationAttribute ( ? string $ operationName , string $ key , $ defaultValue = null , bool $ resourceFallback = false ) { return $ this -> findOperationAttribute ( $ this -> subresourceOperations , $ operationName , $ key , $ defaultValue , $ resourceFallback ) ; }
|
Gets a subresource operation attribute optionally fallback to a resource attribute .
|
3,605
|
public function getTypedOperationAttribute ( string $ operationType , string $ operationName , string $ key , $ defaultValue = null , bool $ resourceFallback = false ) { switch ( $ operationType ) { case OperationType :: COLLECTION : return $ this -> getCollectionOperationAttribute ( $ operationName , $ key , $ defaultValue , $ resourceFallback ) ; case OperationType :: ITEM : return $ this -> getItemOperationAttribute ( $ operationName , $ key , $ defaultValue , $ resourceFallback ) ; default : return $ this -> getSubresourceOperationAttribute ( $ operationName , $ key , $ defaultValue , $ resourceFallback ) ; } }
|
Gets an attribute for a given operation type and operation name .
|
3,606
|
private function findOperationAttribute ( ? array $ operations , ? string $ operationName , string $ key , $ defaultValue , bool $ resourceFallback ) { if ( null !== $ operationName && isset ( $ operations [ $ operationName ] [ $ key ] ) ) { return $ operations [ $ operationName ] [ $ key ] ; } if ( $ resourceFallback && isset ( $ this -> attributes [ $ key ] ) ) { return $ this -> attributes [ $ key ] ; } return $ defaultValue ; }
|
Gets an operation attribute optionally fallback to a resource attribute .
|
3,607
|
private function populateEntrypointProperties ( string $ resourceClass , ResourceMetadata $ resourceMetadata , string $ shortName , string $ prefixedShortName , array & $ entrypointProperties ) { $ hydraCollectionOperations = $ this -> getHydraOperations ( $ resourceClass , $ resourceMetadata , $ prefixedShortName , true ) ; if ( empty ( $ hydraCollectionOperations ) ) { return ; } $ entrypointProperty = [ '@type' => 'hydra:SupportedProperty' , 'hydra:property' => [ '@id' => sprintf ( '#Entrypoint/%s' , lcfirst ( $ shortName ) ) , '@type' => 'hydra:Link' , 'domain' => '#Entrypoint' , 'rdfs:label' => "The collection of $shortName resources" , 'rdfs:range' => [ [ '@id' => 'hydra:Collection' ] , [ 'owl:equivalentClass' => [ 'owl:onProperty' => [ '@id' => 'hydra:member' ] , 'owl:allValuesFrom' => [ '@id' => $ prefixedShortName ] , ] , ] , ] , 'hydra:supportedOperation' => $ hydraCollectionOperations , ] , 'hydra:title' => "The collection of $shortName resources" , 'hydra:readable' => true , 'hydra:writable' => false , ] ; if ( $ resourceMetadata -> getCollectionOperationAttribute ( 'GET' , 'deprecation_reason' , null , true ) ) { $ entrypointProperty [ 'owl:deprecated' ] = true ; } $ entrypointProperties [ ] = $ entrypointProperty ; }
|
Populates entrypoint properties .
|
3,608
|
private function getClass ( string $ resourceClass , ResourceMetadata $ resourceMetadata , string $ shortName , string $ prefixedShortName , array $ context ) : array { $ class = [ '@id' => $ prefixedShortName , '@type' => 'hydra:Class' , 'rdfs:label' => $ shortName , 'hydra:title' => $ shortName , 'hydra:supportedProperty' => $ this -> getHydraProperties ( $ resourceClass , $ resourceMetadata , $ shortName , $ prefixedShortName , $ context ) , 'hydra:supportedOperation' => $ this -> getHydraOperations ( $ resourceClass , $ resourceMetadata , $ prefixedShortName , false ) , ] ; if ( null !== $ description = $ resourceMetadata -> getDescription ( ) ) { $ class [ 'hydra:description' ] = $ description ; } if ( $ resourceMetadata -> getAttribute ( 'deprecation_reason' ) ) { $ class [ 'owl:deprecated' ] = true ; } return $ class ; }
|
Gets a Hydra class .
|
3,609
|
private function getPropertyNameCollectionFactoryContext ( ResourceMetadata $ resourceMetadata ) : array { $ attributes = $ resourceMetadata -> getAttributes ( ) ; $ context = [ ] ; if ( isset ( $ attributes [ 'normalization_context' ] [ AbstractNormalizer :: GROUPS ] ) ) { $ context [ 'serializer_groups' ] = ( array ) $ attributes [ 'normalization_context' ] [ AbstractNormalizer :: GROUPS ] ; } if ( ! isset ( $ attributes [ 'denormalization_context' ] [ AbstractNormalizer :: GROUPS ] ) ) { return $ context ; } if ( isset ( $ context [ 'serializer_groups' ] ) ) { foreach ( ( array ) $ attributes [ 'denormalization_context' ] [ AbstractNormalizer :: GROUPS ] as $ groupName ) { $ context [ 'serializer_groups' ] [ ] = $ groupName ; } return $ context ; } $ context [ 'serializer_groups' ] = ( array ) $ attributes [ 'denormalization_context' ] [ AbstractNormalizer :: GROUPS ] ; return $ context ; }
|
Gets the context for the property name factory .
|
3,610
|
private function getHydraProperties ( string $ resourceClass , ResourceMetadata $ resourceMetadata , string $ shortName , string $ prefixedShortName , array $ context ) : array { $ classes = [ ] ; foreach ( $ resourceMetadata -> getCollectionOperations ( ) as $ operationName => $ operation ) { $ inputMetadata = $ resourceMetadata -> getTypedOperationAttribute ( OperationType :: COLLECTION , $ operationName , 'input' , [ 'class' => $ resourceClass ] , true ) ; if ( null !== $ inputClass = $ inputMetadata [ 'class' ] ?? null ) { $ classes [ $ inputClass ] = true ; } $ outputMetadata = $ resourceMetadata -> getTypedOperationAttribute ( OperationType :: COLLECTION , $ operationName , 'output' , [ 'class' => $ resourceClass ] , true ) ; if ( null !== $ outputClass = $ outputMetadata [ 'class' ] ?? null ) { $ classes [ $ outputClass ] = true ; } } $ properties = [ ] ; foreach ( $ classes as $ class => $ v ) { foreach ( $ this -> propertyNameCollectionFactory -> create ( $ class , $ this -> getPropertyNameCollectionFactoryContext ( $ resourceMetadata ) ) as $ propertyName ) { $ propertyMetadata = $ this -> propertyMetadataFactory -> create ( $ class , $ propertyName ) ; if ( true === $ propertyMetadata -> isIdentifier ( ) && false === $ propertyMetadata -> isWritable ( ) ) { continue ; } if ( $ this -> nameConverter ) { $ propertyName = $ this -> nameConverter -> normalize ( $ propertyName , $ class , self :: FORMAT , $ context ) ; } $ properties [ ] = $ this -> getProperty ( $ propertyMetadata , $ propertyName , $ prefixedShortName , $ shortName ) ; } } return $ properties ; }
|
Gets Hydra properties .
|
3,611
|
private function getHydraOperations ( string $ resourceClass , ResourceMetadata $ resourceMetadata , string $ prefixedShortName , bool $ collection ) : array { if ( null === $ operations = $ collection ? $ resourceMetadata -> getCollectionOperations ( ) : $ resourceMetadata -> getItemOperations ( ) ) { return [ ] ; } $ hydraOperations = [ ] ; foreach ( $ operations as $ operationName => $ operation ) { $ hydraOperations [ ] = $ this -> getHydraOperation ( $ resourceClass , $ resourceMetadata , $ operationName , $ operation , $ prefixedShortName , $ collection ? OperationType :: COLLECTION : OperationType :: ITEM ) ; } if ( null !== $ this -> subresourceOperationFactory ) { foreach ( $ this -> subresourceOperationFactory -> create ( $ resourceClass ) as $ operationId => $ operation ) { $ subresourceMetadata = $ this -> resourceMetadataFactory -> create ( $ operation [ 'resource_class' ] ) ; $ propertyMetadata = $ this -> propertyMetadataFactory -> create ( end ( $ operation [ 'identifiers' ] ) [ 1 ] , $ operation [ 'property' ] ) ; $ hydraOperations [ ] = $ this -> getHydraOperation ( $ resourceClass , $ subresourceMetadata , $ operation [ 'route_name' ] , $ operation , "#{$subresourceMetadata->getShortName()}" , OperationType :: SUBRESOURCE , $ propertyMetadata -> getSubresource ( ) ) ; } } return $ hydraOperations ; }
|
Gets Hydra operations .
|
3,612
|
private function getRange ( PropertyMetadata $ propertyMetadata ) : ? string { $ jsonldContext = $ propertyMetadata -> getAttributes ( ) [ 'jsonld_context' ] ?? [ ] ; if ( isset ( $ jsonldContext [ '@type' ] ) ) { return $ jsonldContext [ '@type' ] ; } if ( null === $ type = $ propertyMetadata -> getType ( ) ) { return null ; } if ( $ type -> isCollection ( ) && null !== $ collectionType = $ type -> getCollectionValueType ( ) ) { $ type = $ collectionType ; } switch ( $ type -> getBuiltinType ( ) ) { case Type :: BUILTIN_TYPE_STRING : return 'xmls:string' ; case Type :: BUILTIN_TYPE_INT : return 'xmls:integer' ; case Type :: BUILTIN_TYPE_FLOAT : return 'xmls:decimal' ; case Type :: BUILTIN_TYPE_BOOL : return 'xmls:boolean' ; case Type :: BUILTIN_TYPE_OBJECT : if ( null === $ className = $ type -> getClassName ( ) ) { return null ; } if ( is_a ( $ className , \ DateTimeInterface :: class , true ) ) { return 'xmls:dateTime' ; } if ( $ this -> resourceClassResolver -> isResourceClass ( $ className ) ) { $ resourceMetadata = $ this -> resourceMetadataFactory -> create ( $ className ) ; return $ resourceMetadata -> getIri ( ) ?? "#{$resourceMetadata->getShortName()}" ; } break ; } return null ; }
|
Gets the range of the property .
|
3,613
|
private function getClasses ( array $ entrypointProperties , array $ classes ) : array { $ classes [ ] = [ '@id' => '#Entrypoint' , '@type' => 'hydra:Class' , 'hydra:title' => 'The API entrypoint' , 'hydra:supportedProperty' => $ entrypointProperties , 'hydra:supportedOperation' => [ '@type' => 'hydra:Operation' , 'hydra:method' => 'GET' , 'rdfs:label' => 'The API entrypoint.' , 'returns' => '#EntryPoint' , ] , ] ; $ classes [ ] = [ '@id' => '#ConstraintViolation' , '@type' => 'hydra:Class' , 'hydra:title' => 'A constraint violation' , 'hydra:supportedProperty' => [ [ '@type' => 'hydra:SupportedProperty' , 'hydra:property' => [ '@id' => '#ConstraintViolation/propertyPath' , '@type' => 'rdf:Property' , 'rdfs:label' => 'propertyPath' , 'domain' => '#ConstraintViolation' , 'range' => 'xmls:string' , ] , 'hydra:title' => 'propertyPath' , 'hydra:description' => 'The property path of the violation' , 'hydra:readable' => true , 'hydra:writable' => false , ] , [ '@type' => 'hydra:SupportedProperty' , 'hydra:property' => [ '@id' => '#ConstraintViolation/message' , '@type' => 'rdf:Property' , 'rdfs:label' => 'message' , 'domain' => '#ConstraintViolation' , 'range' => 'xmls:string' , ] , 'hydra:title' => 'message' , 'hydra:description' => 'The message associated with the violation' , 'hydra:readable' => true , 'hydra:writable' => false , ] , ] , ] ; $ classes [ ] = [ '@id' => '#ConstraintViolationList' , '@type' => 'hydra:Class' , 'subClassOf' => 'hydra:Error' , 'hydra:title' => 'A constraint violation list' , 'hydra:supportedProperty' => [ [ '@type' => 'hydra:SupportedProperty' , 'hydra:property' => [ '@id' => '#ConstraintViolationList/violations' , '@type' => 'rdf:Property' , 'rdfs:label' => 'violations' , 'domain' => '#ConstraintViolationList' , 'range' => '#ConstraintViolation' , ] , 'hydra:title' => 'violations' , 'hydra:description' => 'The violations' , 'hydra:readable' => true , 'hydra:writable' => false , ] , ] , ] ; return $ classes ; }
|
Builds the classes array .
|
3,614
|
private function getProperty ( PropertyMetadata $ propertyMetadata , string $ propertyName , string $ prefixedShortName , string $ shortName ) : array { $ propertyData = [ '@id' => $ propertyMetadata -> getIri ( ) ?? "#$shortName/$propertyName" , '@type' => $ propertyMetadata -> isReadableLink ( ) ? 'rdf:Property' : 'hydra:Link' , 'rdfs:label' => $ propertyName , 'domain' => $ prefixedShortName , ] ; $ type = $ propertyMetadata -> getType ( ) ; if ( null !== $ type && ! $ type -> isCollection ( ) && ( null !== $ className = $ type -> getClassName ( ) ) && $ this -> resourceClassResolver -> isResourceClass ( $ className ) ) { $ propertyData [ 'owl:maxCardinality' ] = 1 ; } $ property = [ '@type' => 'hydra:SupportedProperty' , 'hydra:property' => $ propertyData , 'hydra:title' => $ propertyName , 'hydra:required' => $ propertyMetadata -> isRequired ( ) , 'hydra:readable' => $ propertyMetadata -> isReadable ( ) , 'hydra:writable' => $ propertyMetadata -> isWritable ( ) || $ propertyMetadata -> isInitializable ( ) , ] ; if ( null !== $ range = $ this -> getRange ( $ propertyMetadata ) ) { $ property [ 'hydra:property' ] [ 'range' ] = $ range ; } if ( null !== $ description = $ propertyMetadata -> getDescription ( ) ) { $ property [ 'hydra:description' ] = $ description ; } if ( $ propertyMetadata -> getAttribute ( 'deprecation_reason' ) ) { $ property [ 'owl:deprecated' ] = true ; } return $ property ; }
|
Gets a property definition .
|
3,615
|
private function computeDoc ( Documentation $ object , array $ classes ) : array { $ doc = [ '@context' => $ this -> getContext ( ) , '@id' => $ this -> urlGenerator -> generate ( 'api_doc' , [ '_format' => self :: FORMAT ] ) , '@type' => 'hydra:ApiDocumentation' ] ; if ( '' !== $ object -> getTitle ( ) ) { $ doc [ 'hydra:title' ] = $ object -> getTitle ( ) ; } if ( '' !== $ object -> getDescription ( ) ) { $ doc [ 'hydra:description' ] = $ object -> getDescription ( ) ; } $ doc [ 'hydra:entrypoint' ] = $ this -> urlGenerator -> generate ( 'api_entrypoint' ) ; $ doc [ 'hydra:supportedClass' ] = $ classes ; return $ doc ; }
|
Computes the documentation .
|
3,616
|
private function getContext ( ) : array { return [ '@vocab' => $ this -> urlGenerator -> generate ( 'api_doc' , [ '_format' => self :: FORMAT ] , UrlGeneratorInterface :: ABS_URL ) . '#' , 'hydra' => ContextBuilderInterface :: HYDRA_NS , 'rdf' => ContextBuilderInterface :: RDF_NS , 'rdfs' => ContextBuilderInterface :: RDFS_NS , 'xmls' => ContextBuilderInterface :: XML_NS , 'owl' => ContextBuilderInterface :: OWL_NS , 'schema' => ContextBuilderInterface :: SCHEMA_ORG_NS , 'domain' => [ '@id' => 'rdfs:domain' , '@type' => '@id' ] , 'range' => [ '@id' => 'rdfs:range' , '@type' => '@id' ] , 'subClassOf' => [ '@id' => 'rdfs:subClassOf' , '@type' => '@id' ] , 'expects' => [ '@id' => 'hydra:expects' , '@type' => '@id' ] , 'returns' => [ '@id' => 'hydra:returns' , '@type' => '@id' ] , ] ; }
|
Builds the JSON - LD context for the API documentation .
|
3,617
|
protected function isIdentifier ( string $ resourceClass , string $ property ) : bool { return $ property === $ this -> identifierExtractor -> getIdentifierFromResourceClass ( $ resourceClass ) ; }
|
Is the given property of the given resource class an identifier?
|
3,618
|
private function getManager ( $ data ) : ? DoctrineObjectManager { return \ is_object ( $ data ) ? $ this -> managerRegistry -> getManagerForClass ( $ this -> getObjectClass ( $ data ) ) : null ; }
|
Gets the Doctrine object manager associated with given data .
|
3,619
|
private function isDeferredExplicit ( DoctrineObjectManager $ manager , $ data ) : bool { $ classMetadata = $ manager -> getClassMetadata ( $ this -> getObjectClass ( $ data ) ) ; if ( $ classMetadata instanceof ClassMetadataInfo && method_exists ( $ classMetadata , 'isChangeTrackingDeferredExplicit' ) ) { return $ classMetadata -> isChangeTrackingDeferredExplicit ( ) ; } return false ; }
|
Checks if doctrine does not manage data automatically .
|
3,620
|
public function preUpdate ( PreUpdateEventArgs $ eventArgs ) : void { $ object = $ eventArgs -> getObject ( ) ; $ this -> gatherResourceAndItemTags ( $ object , true ) ; $ changeSet = $ eventArgs -> getEntityChangeSet ( ) ; $ associationMappings = $ eventArgs -> getEntityManager ( ) -> getClassMetadata ( ClassUtils :: getClass ( $ eventArgs -> getObject ( ) ) ) -> getAssociationMappings ( ) ; foreach ( $ changeSet as $ key => $ value ) { if ( ! isset ( $ associationMappings [ $ key ] ) ) { continue ; } $ this -> addTagsFor ( $ value [ 0 ] ) ; $ this -> addTagsFor ( $ value [ 1 ] ) ; } }
|
Collects tags from the previous and the current version of the updated entities to purge related documents .
|
3,621
|
public function onFlush ( OnFlushEventArgs $ eventArgs ) : void { $ em = $ eventArgs -> getEntityManager ( ) ; $ uow = $ em -> getUnitOfWork ( ) ; foreach ( $ uow -> getScheduledEntityInsertions ( ) as $ entity ) { $ this -> gatherResourceAndItemTags ( $ entity , false ) ; $ this -> gatherRelationTags ( $ em , $ entity ) ; } foreach ( $ uow -> getScheduledEntityUpdates ( ) as $ entity ) { $ this -> gatherResourceAndItemTags ( $ entity , true ) ; $ this -> gatherRelationTags ( $ em , $ entity ) ; } foreach ( $ uow -> getScheduledEntityDeletions ( ) as $ entity ) { $ this -> gatherResourceAndItemTags ( $ entity , true ) ; $ this -> gatherRelationTags ( $ em , $ entity ) ; } }
|
Collects tags from inserted and deleted entities including relations .
|
3,622
|
public function postFlush ( ) : void { if ( empty ( $ this -> tags ) ) { return ; } $ this -> purger -> purge ( $ this -> tags ) ; $ this -> tags = [ ] ; }
|
Purges tags collected during this request and clears the tag list .
|
3,623
|
public function onKernelResponse ( FilterResponseEvent $ event ) : void { $ request = $ event -> getRequest ( ) ; $ response = $ event -> getResponse ( ) ; if ( ! $ request -> isMethodCacheable ( ) || ! $ response -> isCacheable ( ) || ( ! $ attributes = RequestAttributesExtractor :: extractAttributes ( $ request ) ) ) { return ; } $ resources = $ request -> attributes -> get ( '_resources' ) ; if ( isset ( $ attributes [ 'collection_operation_name' ] ) || ( $ attributes [ 'subresource_context' ] [ 'collection' ] ?? false ) ) { $ iri = $ this -> iriConverter -> getIriFromResourceClass ( $ attributes [ 'resource_class' ] ) ; $ resources [ $ iri ] = $ iri ; } if ( ! $ resources ) { return ; } $ response -> headers -> set ( 'Cache-Tags' , implode ( ',' , $ resources ) ) ; }
|
Adds the Cache - Tags header .
|
3,624
|
protected function addMatch ( Builder $ aggregationBuilder , string $ field , string $ matchField , string $ operator , string $ value ) { switch ( $ operator ) { case self :: PARAMETER_BETWEEN : $ rangeValue = explode ( '..' , $ value ) ; $ rangeValue = $ this -> normalizeBetweenValues ( $ rangeValue ) ; if ( null === $ rangeValue ) { return ; } $ aggregationBuilder -> match ( ) -> field ( $ matchField ) -> gte ( $ rangeValue [ 0 ] ) -> lte ( $ rangeValue [ 1 ] ) ; break ; case self :: PARAMETER_GREATER_THAN : $ value = $ this -> normalizeValue ( $ value , $ operator ) ; if ( null === $ value ) { return ; } $ aggregationBuilder -> match ( ) -> field ( $ matchField ) -> gt ( $ value ) ; break ; case self :: PARAMETER_GREATER_THAN_OR_EQUAL : $ value = $ this -> normalizeValue ( $ value , $ operator ) ; if ( null === $ value ) { return ; } $ aggregationBuilder -> match ( ) -> field ( $ matchField ) -> gte ( $ value ) ; break ; case self :: PARAMETER_LESS_THAN : $ value = $ this -> normalizeValue ( $ value , $ operator ) ; if ( null === $ value ) { return ; } $ aggregationBuilder -> match ( ) -> field ( $ matchField ) -> lt ( $ value ) ; break ; case self :: PARAMETER_LESS_THAN_OR_EQUAL : $ value = $ this -> normalizeValue ( $ value , $ operator ) ; if ( null === $ value ) { return ; } $ aggregationBuilder -> match ( ) -> field ( $ matchField ) -> lte ( $ value ) ; break ; } }
|
Adds the match stage according to the operator .
|
3,625
|
protected function addWhere ( QueryBuilder $ queryBuilder , QueryNameGeneratorInterface $ queryNameGenerator , string $ alias , string $ field , string $ operator , string $ value , string $ nullManagement = null , $ type = null ) { $ type = ( string ) $ type ; try { $ value = false === strpos ( $ type , '_immutable' ) ? new \ DateTime ( $ value ) : new \ DateTimeImmutable ( $ value ) ; } catch ( \ Exception $ e ) { $ this -> logger -> notice ( 'Invalid filter ignored' , [ 'exception' => new InvalidArgumentException ( sprintf ( 'The field "%s" has a wrong date format. Use one accepted by the \DateTime constructor' , $ field ) ) , ] ) ; return ; } $ valueParameter = $ queryNameGenerator -> generateParameterName ( $ field ) ; $ operatorValue = [ self :: PARAMETER_BEFORE => '<=' , self :: PARAMETER_STRICTLY_BEFORE => '<' , self :: PARAMETER_AFTER => '>=' , self :: PARAMETER_STRICTLY_AFTER => '>' , ] ; $ baseWhere = sprintf ( '%s.%s %s :%s' , $ alias , $ field , $ operatorValue [ $ operator ] , $ valueParameter ) ; if ( null === $ nullManagement || self :: EXCLUDE_NULL === $ nullManagement ) { $ queryBuilder -> andWhere ( $ baseWhere ) ; } elseif ( ( self :: INCLUDE_NULL_BEFORE === $ nullManagement && \ in_array ( $ operator , [ self :: PARAMETER_BEFORE , self :: PARAMETER_STRICTLY_BEFORE ] , true ) ) || ( self :: INCLUDE_NULL_AFTER === $ nullManagement && \ in_array ( $ operator , [ self :: PARAMETER_AFTER , self :: PARAMETER_STRICTLY_AFTER ] , true ) ) || ( self :: INCLUDE_NULL_BEFORE_AND_AFTER === $ nullManagement && \ in_array ( $ operator , [ self :: PARAMETER_AFTER , self :: PARAMETER_STRICTLY_AFTER , self :: PARAMETER_BEFORE , self :: PARAMETER_STRICTLY_BEFORE ] , true ) ) ) { $ queryBuilder -> andWhere ( $ queryBuilder -> expr ( ) -> orX ( $ baseWhere , $ queryBuilder -> expr ( ) -> isNull ( sprintf ( '%s.%s' , $ alias , $ field ) ) ) ) ; } else { $ queryBuilder -> andWhere ( $ queryBuilder -> expr ( ) -> andX ( $ baseWhere , $ queryBuilder -> expr ( ) -> isNotNull ( sprintf ( '%s.%s' , $ alias , $ field ) ) ) ) ; } $ queryBuilder -> setParameter ( $ valueParameter , $ value , $ type ) ; }
|
Adds the where clause according to the chosen null management .
|
3,626
|
public static function addJoinOnce ( QueryBuilder $ queryBuilder , QueryNameGeneratorInterface $ queryNameGenerator , string $ alias , string $ association , string $ joinType = null , string $ conditionType = null , string $ condition = null , string $ originAlias = null ) : string { $ join = self :: getExistingJoin ( $ queryBuilder , $ alias , $ association , $ originAlias ) ; if ( null !== $ join ) { return $ join -> getAlias ( ) ; } $ associationAlias = $ queryNameGenerator -> generateJoinAlias ( $ association ) ; $ query = "$alias.$association" ; if ( Join :: LEFT_JOIN === $ joinType || QueryChecker :: hasLeftJoin ( $ queryBuilder ) ) { $ queryBuilder -> leftJoin ( $ query , $ associationAlias , $ conditionType , $ condition ) ; } else { $ queryBuilder -> innerJoin ( $ query , $ associationAlias , $ conditionType , $ condition ) ; } return $ associationAlias ; }
|
Adds a join to the QueryBuilder if none exists .
|
3,627
|
public static function getEntityClassByAlias ( string $ alias , QueryBuilder $ queryBuilder , ManagerRegistry $ managerRegistry ) : string { if ( ! \ in_array ( $ alias , $ queryBuilder -> getAllAliases ( ) , true ) ) { throw new \ LogicException ( sprintf ( 'The alias "%s" does not exist in the QueryBuilder.' , $ alias ) ) ; } $ rootAliasMap = self :: mapRootAliases ( $ queryBuilder -> getRootAliases ( ) , $ queryBuilder -> getRootEntities ( ) ) ; if ( isset ( $ rootAliasMap [ $ alias ] ) ) { return $ rootAliasMap [ $ alias ] ; } $ metadata = null ; foreach ( self :: traverseJoins ( $ alias , $ queryBuilder , $ managerRegistry ) as [ $ currentMetadata ] ) { $ metadata = $ currentMetadata ; } if ( null === $ metadata ) { throw new \ LogicException ( sprintf ( 'The alias "%s" does not exist in the QueryBuilder.' , $ alias ) ) ; } return $ metadata -> getName ( ) ; }
|
Gets the entity class name by an alias used in the QueryBuilder .
|
3,628
|
public static function findRootAlias ( string $ alias , QueryBuilder $ queryBuilder ) : string { if ( \ in_array ( $ alias , $ queryBuilder -> getRootAliases ( ) , true ) ) { return $ alias ; } foreach ( $ queryBuilder -> getDQLPart ( 'join' ) as $ rootAlias => $ joins ) { foreach ( $ joins as $ join ) { if ( $ alias === $ join -> getAlias ( ) ) { return $ rootAlias ; } } } throw new \ LogicException ( sprintf ( 'The alias "%s" does not exist in the QueryBuilder.' , $ alias ) ) ; }
|
Finds the root alias for an alias used in the QueryBuilder .
|
3,629
|
public static function traverseJoins ( string $ alias , QueryBuilder $ queryBuilder , ManagerRegistry $ managerRegistry ) : \ Generator { $ rootAliasMap = self :: mapRootAliases ( $ queryBuilder -> getRootAliases ( ) , $ queryBuilder -> getRootEntities ( ) ) ; $ joinParts = $ queryBuilder -> getDQLPart ( 'join' ) ; $ rootAlias = self :: findRootAlias ( $ alias , $ queryBuilder ) ; $ joinAliasMap = self :: mapJoinAliases ( $ joinParts [ $ rootAlias ] ) ; $ aliasMap = array_merge ( $ rootAliasMap , $ joinAliasMap ) ; $ apexEntityClass = null ; $ associationStack = [ ] ; $ aliasStack = [ ] ; $ currentAlias = $ alias ; while ( null === $ apexEntityClass ) { if ( ! isset ( $ aliasMap [ $ currentAlias ] ) ) { throw new \ LogicException ( sprintf ( 'Unknown alias "%s".' , $ currentAlias ) ) ; } if ( \ is_string ( $ aliasMap [ $ currentAlias ] ) ) { $ aliasStack [ ] = $ currentAlias ; $ apexEntityClass = $ aliasMap [ $ currentAlias ] ; } else { [ $ parentAlias , $ association ] = $ aliasMap [ $ currentAlias ] ; $ associationStack [ ] = $ association ; $ aliasStack [ ] = $ currentAlias ; $ currentAlias = $ parentAlias ; } } $ entityClass = $ apexEntityClass ; while ( null !== ( $ alias = array_pop ( $ aliasStack ) ) ) { $ metadata = $ managerRegistry -> getManagerForClass ( $ entityClass ) -> getClassMetadata ( $ entityClass ) ; $ association = array_pop ( $ associationStack ) ; yield $ alias => [ $ metadata , $ association , ] ; if ( null !== $ association ) { $ entityClass = $ metadata -> getAssociationTargetClass ( $ association ) ; } } }
|
Traverses through the joins for an alias used in the QueryBuilder .
|
3,630
|
private static function getExistingJoin ( QueryBuilder $ queryBuilder , string $ alias , string $ association , string $ originAlias = null ) : ? Join { $ parts = $ queryBuilder -> getDQLPart ( 'join' ) ; $ rootAlias = $ originAlias ?? $ queryBuilder -> getRootAliases ( ) [ 0 ] ; if ( ! isset ( $ parts [ $ rootAlias ] ) ) { return null ; } foreach ( $ parts [ $ rootAlias ] as $ join ) { if ( sprintf ( '%s.%s' , $ alias , $ association ) === $ join -> getJoin ( ) ) { return $ join ; } } return null ; }
|
Gets the existing join from QueryBuilder DQL parts .
|
3,631
|
private static function mapRootAliases ( array $ rootAliases , array $ rootEntities ) : array { $ aliasMap = array_combine ( $ rootAliases , $ rootEntities ) ; if ( false === $ aliasMap ) { throw new \ LogicException ( 'Number of root aliases and root entities do not match.' ) ; } return $ aliasMap ; }
|
Maps the root aliases to root entity classes .
|
3,632
|
private static function mapJoinAliases ( iterable $ joins ) : array { $ aliasMap = [ ] ; foreach ( $ joins as $ join ) { $ alias = $ join -> getAlias ( ) ; $ relationship = $ join -> getJoin ( ) ; if ( false !== strpos ( $ relationship , '.' ) ) { $ aliasMap [ $ alias ] = explode ( '.' , $ relationship ) ; } else { $ aliasMap [ $ alias ] = $ relationship ; } } return $ aliasMap ; }
|
Maps the join aliases to the parent alias and association or the entity class .
|
3,633
|
private function getOperationFormats ( array $ annotationFormats ) : array { $ resourceFormats = [ ] ; foreach ( $ annotationFormats as $ format => $ value ) { if ( ! is_numeric ( $ format ) ) { $ resourceFormats [ $ format ] = ( array ) $ value ; continue ; } if ( ! \ is_string ( $ value ) ) { throw new InvalidArgumentException ( sprintf ( "The 'formats' attributes value must be a string when trying to include an already configured format, %s given." , \ gettype ( $ value ) ) ) ; } if ( \ array_key_exists ( $ value , $ this -> configuredFormats ) ) { $ resourceFormats [ $ value ] = $ this -> configuredFormats [ $ value ] ; continue ; } throw new InvalidArgumentException ( sprintf ( "You either need to add the format '%s' to your project configuration or declare a mime type for it in your annotation." , $ value ) ) ; } return $ resourceFormats ; }
|
Filter and populate the acceptable formats .
|
3,634
|
private function isNestedField ( string $ resourceClass , string $ property ) : bool { return null !== $ this -> getNestedFieldPath ( $ resourceClass , $ property ) ; }
|
Is the decomposed given property of the given resource class potentially mapped as a nested field in Elasticsearch?
|
3,635
|
private function shouldOperationForceEager ( string $ resourceClass , array $ options ) : bool { return $ this -> getBooleanOperationAttribute ( $ resourceClass , $ options , 'force_eager' , $ this -> forceEager ) ; }
|
Checks if an operation has a force_eager attribute .
|
3,636
|
private function shouldOperationFetchPartial ( string $ resourceClass , array $ options ) : bool { return $ this -> getBooleanOperationAttribute ( $ resourceClass , $ options , 'fetch_partial' , $ this -> fetchPartial ) ; }
|
Checks if an operation has a fetch_partial attribute .
|
3,637
|
private function getBooleanOperationAttribute ( string $ resourceClass , array $ options , string $ attributeName , bool $ default ) : bool { $ resourceMetadata = $ this -> resourceMetadataFactory -> create ( $ resourceClass ) ; if ( isset ( $ options [ 'collection_operation_name' ] ) ) { $ attribute = $ resourceMetadata -> getCollectionOperationAttribute ( $ options [ 'collection_operation_name' ] , $ attributeName , null , true ) ; } elseif ( isset ( $ options [ 'item_operation_name' ] ) ) { $ attribute = $ resourceMetadata -> getItemOperationAttribute ( $ options [ 'item_operation_name' ] , $ attributeName , null , true ) ; } else { $ attribute = $ resourceMetadata -> getAttribute ( $ attributeName ) ; } return \ is_bool ( $ attribute ) ? $ attribute : $ default ; }
|
Get the boolean attribute of an operation or the resource metadata .
|
3,638
|
private function hasFetchEagerAssociation ( EntityManager $ em , ClassMetadataInfo $ classMetadata , array & $ checked = [ ] ) : bool { $ checked [ ] = $ classMetadata -> name ; foreach ( $ classMetadata -> getAssociationMappings ( ) as $ mapping ) { if ( ClassMetadataInfo :: FETCH_EAGER === $ mapping [ 'fetch' ] ) { return true ; } $ related = $ em -> getClassMetadata ( $ mapping [ 'targetEntity' ] ) ; if ( \ in_array ( $ related -> name , $ checked , true ) ) { continue ; } if ( true === $ this -> hasFetchEagerAssociation ( $ em , $ related , $ checked ) ) { return true ; } } return false ; }
|
Checks if the class has an associationMapping with FETCH = EAGER .
|
3,639
|
private function normalizeIdentifiers ( $ id , ObjectManager $ manager , string $ resourceClass ) : array { $ identifierValues = [ $ id ] ; $ doctrineClassMetadata = $ manager -> getClassMetadata ( $ resourceClass ) ; $ doctrineIdentifierFields = $ doctrineClassMetadata -> getIdentifier ( ) ; $ isOrm = $ manager instanceof EntityManagerInterface ; $ isOdm = $ manager instanceof DocumentManager ; $ platform = $ isOrm ? $ manager -> getConnection ( ) -> getDatabasePlatform ( ) : null ; $ identifiersMap = null ; if ( \ count ( $ doctrineIdentifierFields ) > 1 ) { $ identifiersMap = [ ] ; foreach ( explode ( ';' , ( string ) $ id ) as $ identifier ) { if ( ! $ identifier ) { continue ; } $ identifierPair = explode ( '=' , $ identifier ) ; $ identifiersMap [ $ identifierPair [ 0 ] ] = $ identifierPair [ 1 ] ; } } $ identifiers = [ ] ; $ i = 0 ; foreach ( $ this -> propertyNameCollectionFactory -> create ( $ resourceClass ) as $ propertyName ) { $ propertyMetadata = $ this -> propertyMetadataFactory -> create ( $ resourceClass , $ propertyName ) ; if ( ! $ propertyMetadata -> isIdentifier ( ) ) { continue ; } $ identifier = null === $ identifiersMap ? $ identifierValues [ $ i ] ?? null : $ identifiersMap [ $ propertyName ] ?? null ; if ( null === $ identifier ) { throw new PropertyNotFoundException ( sprintf ( 'Invalid identifier "%s", "%s" was not found.' , $ id , $ propertyName ) ) ; } $ doctrineTypeName = $ doctrineClassMetadata -> getTypeOfField ( $ propertyName ) ; if ( $ isOrm && null !== $ doctrineTypeName && DBALType :: hasType ( $ doctrineTypeName ) ) { $ identifier = DBALType :: getType ( $ doctrineTypeName ) -> convertToPHPValue ( $ identifier , $ platform ) ; } if ( $ isOdm && null !== $ doctrineTypeName && MongoDbType :: hasType ( $ doctrineTypeName ) ) { $ identifier = MongoDbType :: getType ( $ doctrineTypeName ) -> convertToPHPValue ( $ identifier ) ; } $ identifiers [ $ propertyName ] = $ identifier ; ++ $ i ; } return $ identifiers ; }
|
Transform and check the identifier composite or not .
|
3,640
|
public function getGroupId ( ) { if ( ! $ this -> isGroupEvent ( ) ) { throw new InvalidEventSourceException ( 'This event source is not a group type' ) ; } return isset ( $ this -> event [ 'source' ] [ 'groupId' ] ) ? $ this -> event [ 'source' ] [ 'groupId' ] : null ; }
|
Returns group ID of the event .
|
3,641
|
public function getRoomId ( ) { if ( ! $ this -> isRoomEvent ( ) ) { throw new InvalidEventSourceException ( 'This event source is not a room type' ) ; } return isset ( $ this -> event [ 'source' ] [ 'roomId' ] ) ? $ this -> event [ 'source' ] [ 'roomId' ] : null ; }
|
Returns room ID of the event .
|
3,642
|
public function buildMessage ( ) { if ( ! empty ( $ this -> message ) ) { return $ this -> message ; } $ locationMessage = [ 'type' => MessageType :: LOCATION , 'title' => $ this -> title , 'address' => $ this -> address , 'latitude' => $ this -> latitude , 'longitude' => $ this -> longitude , ] ; if ( $ this -> quickReply ) { $ locationMessage [ 'quickReply' ] = $ this -> quickReply -> buildQuickReply ( ) ; } $ this -> message [ ] = $ locationMessage ; return $ this -> message ; }
|
Builds location message structure .
|
3,643
|
public function replyMessage ( $ replyToken , MessageBuilder $ messageBuilder ) { return $ this -> httpClient -> post ( $ this -> endpointBase . '/v2/bot/message/reply' , [ 'replyToken' => $ replyToken , 'messages' => $ messageBuilder -> buildMessage ( ) , ] ) ; }
|
Replies arbitrary message to destination which is associated with reply token .
|
3,644
|
public function pushMessage ( $ to , MessageBuilder $ messageBuilder ) { return $ this -> httpClient -> post ( $ this -> endpointBase . '/v2/bot/message/push' , [ 'to' => $ to , 'messages' => $ messageBuilder -> buildMessage ( ) , ] ) ; }
|
Sends arbitrary message to destination .
|
3,645
|
public function multicast ( array $ tos , MessageBuilder $ messageBuilder ) { return $ this -> httpClient -> post ( $ this -> endpointBase . '/v2/bot/message/multicast' , [ 'to' => $ tos , 'messages' => $ messageBuilder -> buildMessage ( ) , ] ) ; }
|
Sends arbitrary message to multi destinations .
|
3,646
|
public function parseEventRequest ( $ body , $ signature , $ eventOnly = true ) { return EventRequestParser :: parseEventRequest ( $ body , $ this -> channelSecret , $ signature , $ eventOnly ) ; }
|
Parse event request to Event objects .
|
3,647
|
public function getGroupMemberProfile ( $ groupId , $ userId ) { $ url = sprintf ( '%s/v2/bot/group/%s/member/%s' , $ this -> endpointBase , urlencode ( $ groupId ) , urlencode ( $ userId ) ) ; return $ this -> httpClient -> get ( $ url , [ ] ) ; }
|
Gets the user profile of a member of a group that the bot is in . This can be the user ID of a user who has not added the bot as a friend or has blocked the bot .
|
3,648
|
public function getRoomMemberProfile ( $ roomId , $ userId ) { $ url = sprintf ( '%s/v2/bot/room/%s/member/%s' , $ this -> endpointBase , urlencode ( $ roomId ) , urlencode ( $ userId ) ) ; return $ this -> httpClient -> get ( $ url , [ ] ) ; }
|
Gets the user profile of a member of a room that the bot is in . This can be the user ID of a user who has not added the bot as a friend or has blocked the bot .
|
3,649
|
public function getGroupMemberIds ( $ groupId , $ start = null ) { $ url = sprintf ( '%s/v2/bot/group/%s/members/ids' , $ this -> endpointBase , urlencode ( $ groupId ) ) ; $ params = is_null ( $ start ) ? [ ] : [ 'start' => $ start ] ; return $ this -> httpClient -> get ( $ url , $ params ) ; }
|
Gets the user IDs of the members of a group that the bot is in . This includes the user IDs of users who have not added the bot as a friend or has blocked the bot .
|
3,650
|
public function getRoomMemberIds ( $ roomId , $ start = null ) { $ url = sprintf ( '%s/v2/bot/room/%s/members/ids' , $ this -> endpointBase , urlencode ( $ roomId ) ) ; $ params = is_null ( $ start ) ? [ ] : [ 'start' => $ start ] ; return $ this -> httpClient -> get ( $ url , $ params ) ; }
|
Gets the user IDs of the members of a room that the bot is in . This includes the user IDs of users who have not added the bot as a friend or has blocked the bot .
|
3,651
|
public function createLinkToken ( $ userId ) { $ url = sprintf ( '%s/v2/bot/user/%s/linkToken' , $ this -> endpointBase , urlencode ( $ userId ) ) ; return $ this -> httpClient -> post ( $ url , [ ] ) ; }
|
Issues a link token used for the account link feature .
|
3,652
|
public function deleteRichMenu ( $ richMenuId ) { $ url = sprintf ( '%s/v2/bot/richmenu/%s' , $ this -> endpointBase , urlencode ( $ richMenuId ) ) ; return $ this -> httpClient -> delete ( $ url ) ; }
|
Deletes a rich menu .
|
3,653
|
public function getRichMenuId ( $ userId ) { $ url = sprintf ( '%s/v2/bot/user/%s/richmenu' , $ this -> endpointBase , urlencode ( $ userId ) ) ; return $ this -> httpClient -> get ( $ url , [ ] ) ; }
|
Gets the ID of the rich menu linked to a user .
|
3,654
|
public function linkRichMenu ( $ userId , $ richMenuId ) { $ url = sprintf ( '%s/v2/bot/user/%s/richmenu/%s' , $ this -> endpointBase , urlencode ( $ userId ) , urlencode ( $ richMenuId ) ) ; return $ this -> httpClient -> post ( $ url , [ ] ) ; }
|
Links a rich menu to a user . Only one rich menu can be linked to a user at one time .
|
3,655
|
public function bulkLinkRichMenu ( $ userIds , $ richMenuId ) { $ url = $ this -> endpointBase . '/v2/bot/richmenu/bulk/link' ; return $ this -> httpClient -> post ( $ url , [ 'richMenuId' => $ richMenuId , 'userIds' => $ userIds ] ) ; }
|
Links a rich menu to multiple users .
|
3,656
|
public function unlinkRichMenu ( $ userId ) { $ url = sprintf ( '%s/v2/bot/user/%s/richmenu' , $ this -> endpointBase , urlencode ( $ userId ) ) ; return $ this -> httpClient -> delete ( $ url ) ; }
|
Unlinks a rich menu from multiple user .
|
3,657
|
public function bulkUnlinkRichMenu ( $ userIds ) { $ url = $ this -> endpointBase . '/v2/bot/richmenu/bulk/unlink' ; return $ this -> httpClient -> post ( $ url , [ 'userIds' => $ userIds ] ) ; }
|
Unlinks rich menus from multiple users .
|
3,658
|
public function downloadRichMenuImage ( $ richMenuId ) { $ url = sprintf ( '%s/v2/bot/richmenu/%s/content' , $ this -> endpointBase , urlencode ( $ richMenuId ) ) ; return $ this -> httpClient -> get ( $ url ) ; }
|
Downloads an image associated with a rich menu .
|
3,659
|
public function uploadRichMenuImage ( $ richMenuId , $ imagePath , $ contentType ) { $ url = sprintf ( '%s/v2/bot/richmenu/%s/content' , $ this -> endpointBase , urlencode ( $ richMenuId ) ) ; return $ this -> httpClient -> post ( $ url , [ '__file' => $ imagePath , '__type' => $ contentType , ] , [ "Content-Type: $contentType" ] ) ; }
|
Uploads and attaches an image to a rich menu .
|
3,660
|
public function getNumberOfSentReplyMessages ( DateTime $ datetime ) { $ url = $ this -> endpointBase . '/v2/bot/message/delivery/reply' ; $ datetime -> setTimezone ( new DateTimeZone ( 'Asia/Tokyo' ) ) ; return $ this -> httpClient -> get ( $ url , [ 'date' => $ datetime -> format ( 'Ymd' ) ] ) ; }
|
Get number of sent reply messages
|
3,661
|
public function build ( ) { if ( isset ( $ this -> style ) ) { return $ this -> style ; } $ this -> style = BuildUtil :: removeNullElements ( [ 'backgroundColor' => $ this -> backgroundColor , 'separator' => $ this -> separator , 'separatorColor' => $ this -> separatorColor , ] ) ; return $ this -> style ; }
|
Builds block style structure .
|
3,662
|
public function build ( ) { if ( isset ( $ this -> component ) ) { return $ this -> component ; } $ this -> component = BuildUtil :: removeNullElements ( [ 'type' => ComponentType :: IMAGE , 'url' => $ this -> url , 'flex' => $ this -> flex , 'margin' => $ this -> margin , 'align' => $ this -> align , 'gravity' => $ this -> gravity , 'size' => $ this -> size , 'aspectRatio' => $ this -> aspectRatio , 'aspectMode' => $ this -> aspectMode , 'backgroundColor' => $ this -> backgroundColor , 'action' => BuildUtil :: build ( $ this -> actionBuilder , 'buildTemplateAction' ) , ] ) ; return $ this -> component ; }
|
Builds image component structure .
|
3,663
|
public function build ( ) { if ( isset ( $ this -> component ) ) { return $ this -> component ; } $ this -> component = BuildUtil :: removeNullElements ( [ 'type' => ComponentType :: TEXT , 'text' => $ this -> text , 'flex' => $ this -> flex , 'margin' => $ this -> margin , 'size' => $ this -> size , 'align' => $ this -> align , 'gravity' => $ this -> gravity , 'wrap' => $ this -> wrap , 'maxLines' => $ this -> maxLines , 'weight' => $ this -> weight , 'color' => $ this -> color , 'action' => BuildUtil :: build ( $ this -> actionBuilder , 'buildTemplateAction' ) , ] ) ; return $ this -> component ; }
|
Builds text component structure .
|
3,664
|
public function buildTemplate ( ) { if ( ! empty ( $ this -> template ) ) { return $ this -> template ; } $ actions = [ ] ; foreach ( $ this -> actionBuilders as $ actionBuilder ) { $ actions [ ] = $ actionBuilder -> buildTemplateAction ( ) ; } $ this -> template = [ 'thumbnailImageUrl' => $ this -> thumbnailImageUrl , 'title' => $ this -> title , 'text' => $ this -> text , 'actions' => $ actions , ] ; if ( $ this -> imageBackgroundColor ) { $ this -> template [ 'imageBackgroundColor' ] = $ this -> imageBackgroundColor ; } return $ this -> template ; }
|
Builds column of carousel template structure .
|
3,665
|
public function build ( ) { if ( ! empty ( $ this -> container ) ) { return $ this -> container ; } $ this -> container = BuildUtil :: removeNullElements ( [ 'type' => ContainerType :: BUBBLE , 'direction' => $ this -> direction , 'header' => BuildUtil :: build ( $ this -> headerComponentBuilder ) , 'hero' => BuildUtil :: build ( $ this -> heroComponentBuilder ) , 'body' => BuildUtil :: build ( $ this -> bodyComponentBuilder ) , 'footer' => BuildUtil :: build ( $ this -> footerComponentBuilder ) , 'styles' => BuildUtil :: build ( $ this -> stylesBuilder ) , ] ) ; return $ this -> container ; }
|
Builds bubble container structure .
|
3,666
|
public function buildTemplate ( ) { if ( ! empty ( $ this -> template ) ) { return $ this -> template ; } $ actions = [ ] ; foreach ( $ this -> actionBuilders as $ actionBuilder ) { $ actions [ ] = $ actionBuilder -> buildTemplateAction ( ) ; } $ this -> template = [ 'type' => TemplateType :: BUTTONS , 'text' => $ this -> text , 'actions' => $ actions , ] ; if ( $ this -> title ) { $ this -> template [ 'title' ] = $ this -> title ; } if ( $ this -> thumbnailImageUrl ) { $ this -> template [ 'thumbnailImageUrl' ] = $ this -> thumbnailImageUrl ; } if ( $ this -> imageAspectRatio ) { $ this -> template [ 'imageAspectRatio' ] = $ this -> imageAspectRatio ; } if ( $ this -> imageSize ) { $ this -> template [ 'imageSize' ] = $ this -> imageSize ; } if ( $ this -> imageBackgroundColor ) { $ this -> template [ 'imageBackgroundColor' ] = $ this -> imageBackgroundColor ; } if ( $ this -> defaultAction ) { $ this -> template [ 'defaultAction' ] = $ this -> defaultAction -> buildTemplateAction ( ) ; } return $ this -> template ; }
|
Builds button template message structure .
|
3,667
|
public function build ( ) { if ( isset ( $ this -> component ) ) { return $ this -> component ; } $ this -> component = BuildUtil :: removeNullElements ( [ 'type' => ComponentType :: SEPARATOR , 'margin' => $ this -> margin , 'color' => $ this -> color , ] ) ; return $ this -> component ; }
|
Builds separator component structure .
|
3,668
|
public function buildMessage ( ) { if ( ! empty ( $ this -> message ) ) { return $ this -> message ; } foreach ( $ this -> texts as $ text ) { $ this -> message [ ] = [ 'type' => MessageType :: TEXT , 'text' => $ text , ] ; } if ( $ this -> quickReply ) { $ lastKey = count ( $ this -> message ) - 1 ; $ this -> message [ $ lastKey ] [ 'quickReply' ] = $ this -> quickReply -> buildQuickReply ( ) ; } return $ this -> message ; }
|
Builds text message structure .
|
3,669
|
public function build ( ) { if ( isset ( $ this -> styles ) ) { return $ this -> styles ; } $ this -> styles = BuildUtil :: removeNullElements ( [ 'header' => BuildUtil :: build ( $ this -> headerStyleBuilder ) , 'hero' => BuildUtil :: build ( $ this -> heroStyleBuilder ) , 'body' => BuildUtil :: build ( $ this -> bodyStyleBuilder ) , 'footer' => BuildUtil :: build ( $ this -> footerStyleBuilder ) , ] ) ; return $ this -> styles ; }
|
Builds bubble styles structure .
|
3,670
|
public function buildMessage ( ) { if ( ! empty ( $ this -> message ) ) { return $ this -> message ; } $ sticker = [ 'type' => MessageType :: STICKER , 'packageId' => $ this -> packageId , 'stickerId' => $ this -> stickerId , ] ; if ( $ this -> quickReply ) { $ sticker [ 'quickReply' ] = $ this -> quickReply -> buildQuickReply ( ) ; } $ this -> message [ ] = $ sticker ; return $ this -> message ; }
|
Builds sticker message structure .
|
3,671
|
public function build ( ) { $ video = [ 'originalContentUrl' => $ this -> originalContentUrl , 'previewImageUrl' => $ this -> previewImageUrl , 'area' => $ this -> areaBuilder -> build ( ) ] ; if ( $ this -> externalLinkBuilder ) { $ video [ 'externalLink' ] = $ this -> externalLinkBuilder -> build ( ) ; } return $ video ; }
|
Builds video of imagemap .
|
3,672
|
public function buildMessage ( ) { if ( ! empty ( $ this -> message ) ) { return $ this -> message ; } $ audioMessage = [ 'type' => MessageType :: AUDIO , 'originalContentUrl' => $ this -> originalContentUrl , 'duration' => $ this -> duration , ] ; if ( $ this -> quickReply ) { $ audioMessage [ 'quickReply' ] = $ this -> quickReply -> buildQuickReply ( ) ; } $ this -> message [ ] = $ audioMessage ; return $ this -> message ; }
|
Build audio message structure .
|
3,673
|
public function buildMessage ( ) { if ( ! empty ( $ this -> message ) ) { return $ this -> message ; } $ imageMessage = [ 'type' => MessageType :: IMAGE , 'originalContentUrl' => $ this -> originalContentUrl , 'previewImageUrl' => $ this -> previewImageUrl , ] ; if ( $ this -> quickReply ) { $ imageMessage [ 'quickReply' ] = $ this -> quickReply -> buildQuickReply ( ) ; } $ this -> message [ ] = $ imageMessage ; return $ this -> message ; }
|
Builds image message structure .
|
3,674
|
public function buildTemplate ( ) { if ( ! empty ( $ this -> template ) ) { return $ this -> template ; } $ actions = [ ] ; foreach ( $ this -> actionBuilders as $ actionBuilder ) { $ actions [ ] = $ actionBuilder -> buildTemplateAction ( ) ; } $ this -> template = [ 'type' => TemplateType :: CONFIRM , 'text' => $ this -> text , 'actions' => $ actions , ] ; return $ this -> template ; }
|
Builds confirm template structure .
|
3,675
|
public function get ( $ url , array $ data = [ ] , array $ headers = [ ] ) { if ( $ data ) { $ url .= '?' . http_build_query ( $ data ) ; } return $ this -> sendRequest ( 'GET' , $ url , $ headers ) ; }
|
Sends GET request to LINE Messaging API .
|
3,676
|
public function post ( $ url , array $ data , array $ headers = null ) { $ headers = is_null ( $ headers ) ? [ 'Content-Type: application/json; charset=utf-8' ] : $ headers ; return $ this -> sendRequest ( 'POST' , $ url , $ headers , $ data ) ; }
|
Sends POST request to LINE Messaging API .
|
3,677
|
public function buildTemplate ( ) { if ( ! empty ( $ this -> template ) ) { return $ this -> template ; } $ this -> template = [ 'imageUrl' => $ this -> imageUrl , 'action' => $ this -> actionBuilder -> buildTemplateAction ( ) , ] ; return $ this -> template ; }
|
Builds column of image carousel template structure .
|
3,678
|
public function buildTemplateAction ( ) { return [ 'type' => ActionType :: DATETIME_PICKER , 'label' => $ this -> label , 'data' => $ this -> data , 'mode' => $ this -> mode , 'initial' => $ this -> initial , 'max' => $ this -> max , 'min' => $ this -> min , ] ; }
|
Builds datetime picker action structure .
|
3,679
|
public function buildTemplateAction ( ) { $ templateAction = BuildUtil :: removeNullElements ( [ 'type' => ActionType :: URI , 'label' => $ this -> label , 'uri' => $ this -> uri , ] ) ; if ( $ this -> altUri ) { $ templateAction [ 'altUri' ] = $ this -> altUri -> build ( ) ; } return $ templateAction ; }
|
Builds URI action structure .
|
3,680
|
public static function validateSignature ( $ body , $ channelSecret , $ signature ) { if ( ! isset ( $ signature ) ) { throw new InvalidSignatureException ( 'Signature must not be empty' ) ; } return hash_equals ( base64_encode ( hash_hmac ( 'sha256' , $ body , $ channelSecret , true ) ) , $ signature ) ; }
|
Validate request with signature .
|
3,681
|
public function build ( ) { if ( isset ( $ this -> component ) ) { return $ this -> component ; } $ this -> component = BuildUtil :: removeNullElements ( [ 'type' => ComponentType :: ICON , 'url' => $ this -> url , 'margin' => $ this -> margin , 'size' => $ this -> size , 'aspectRatio' => $ this -> aspectRatio , ] ) ; return $ this -> component ; }
|
Builds icon component structure .
|
3,682
|
public function build ( ) { if ( isset ( $ this -> component ) ) { return $ this -> component ; } $ this -> component = BuildUtil :: removeNullElements ( [ 'type' => ComponentType :: SPACER , 'size' => $ this -> size , ] ) ; return $ this -> component ; }
|
Builds spacer component structure .
|
3,683
|
public static function get ( ) { return FlexMessageBuilder :: builder ( ) -> setAltText ( 'Shopping' ) -> setContents ( new CarouselContainerBuilder ( [ self :: createItemBubble ( 111 ) , self :: createItemBubble ( 112 ) , self :: createMoreBubble ( ) ] ) ) ; }
|
Create sample shopping flex message
|
3,684
|
public function buildQuickReply ( ) { if ( ! empty ( $ this -> quickReply ) ) { return $ this -> quickReply ; } $ items = [ ] ; foreach ( $ this -> buttonBuilders as $ buttonBuilder ) { $ items [ ] = $ buttonBuilder -> buildQuickReplyButton ( ) ; } $ this -> quickReply = [ 'items' => $ items ] ; return $ this -> quickReply ; }
|
Builds button of quick reply structure .
|
3,685
|
public function build ( ) { if ( isset ( $ this -> component ) ) { return $ this -> component ; } $ contents = array_map ( function ( $ componentBuilder ) { return $ componentBuilder -> build ( ) ; } , $ this -> componentBuilders ) ; $ this -> component = BuildUtil :: removeNullElements ( [ 'type' => ComponentType :: BOX , 'layout' => $ this -> layout , 'contents' => $ contents , 'flex' => $ this -> flex , 'spacing' => $ this -> spacing , 'margin' => $ this -> margin , 'action' => BuildUtil :: build ( $ this -> actionBuilder , 'buildTemplateAction' ) , ] ) ; return $ this -> component ; }
|
Builds box component structure .
|
3,686
|
public static function get ( ) { return FlexMessageBuilder :: builder ( ) -> setAltText ( 'Restaurant' ) -> setContents ( BubbleContainerBuilder :: builder ( ) -> setHero ( self :: createHeroBlock ( ) ) -> setBody ( self :: createBodyBlock ( ) ) -> setFooter ( self :: createFooterBlock ( ) ) ) ; }
|
Create sample restaurant flex message
|
3,687
|
public function buildMessage ( ) { if ( ! empty ( $ this -> message ) ) { return $ this -> message ; } $ actions = [ ] ; foreach ( $ this -> imagemapActionBuilders as $ builder ) { $ actions [ ] = $ builder -> buildImagemapAction ( ) ; } $ imagemapMessage = [ 'type' => MessageType :: IMAGEMAP , 'baseUrl' => $ this -> baseUrl , 'altText' => $ this -> altText , 'baseSize' => $ this -> baseSizeBuilder -> build ( ) , 'actions' => $ actions , ] ; if ( $ this -> quickReply ) { $ imagemapMessage [ 'quickReply' ] = $ this -> quickReply -> buildQuickReply ( ) ; } if ( $ this -> videoBuilder ) { $ imagemapMessage [ 'video' ] = $ this -> videoBuilder -> build ( ) ; } $ this -> message [ ] = $ imagemapMessage ; return $ this -> message ; }
|
Builds imagemap message strucutre .
|
3,688
|
public function buildMessage ( ) { if ( ! empty ( $ this -> message ) ) { return $ this -> message ; } $ templateMessage = [ 'type' => MessageType :: TEMPLATE , 'altText' => $ this -> altText , 'template' => $ this -> templateBuilder -> buildTemplate ( ) , ] ; if ( $ this -> quickReply ) { $ templateMessage [ 'quickReply' ] = $ this -> quickReply -> buildQuickReply ( ) ; } $ this -> message [ ] = $ templateMessage ; return $ this -> message ; }
|
Builds template message structure .
|
3,689
|
public function buildMessage ( ) { if ( isset ( $ this -> message ) ) { return $ this -> message ; } $ this -> message = [ BuildUtil :: removeNullElements ( [ 'type' => MessageType :: FLEX , 'altText' => $ this -> altText , 'contents' => $ this -> containerBuilder -> build ( ) , 'quickReply' => BuildUtil :: build ( $ this -> quickReply , 'buildQuickReply' ) , ] ) ] ; return $ this -> message ; }
|
Builds flex message structure .
|
3,690
|
public function build ( ) { if ( isset ( $ this -> component ) ) { return $ this -> component ; } $ this -> component = BuildUtil :: removeNullElements ( [ 'type' => ComponentType :: BUTTON , 'action' => $ this -> actionBuilder -> buildTemplateAction ( ) , 'flex' => $ this -> flex , 'margin' => $ this -> margin , 'height' => $ this -> height , 'style' => $ this -> style , 'color' => $ this -> color , 'gravity' => $ this -> gravity , ] ) ; return $ this -> component ; }
|
Builds button component structure .
|
3,691
|
public function buildMessage ( ) { if ( ! empty ( $ this -> message ) ) { return $ this -> message ; } $ video = [ 'type' => MessageType :: VIDEO , 'originalContentUrl' => $ this -> originalContentUrl , 'previewImageUrl' => $ this -> previewImageUrl , ] ; if ( $ this -> quickReply ) { $ video [ 'quickReply' ] = $ this -> quickReply -> buildQuickReply ( ) ; } $ this -> message [ ] = $ video ; return $ this -> message ; }
|
Builds video message structure .
|
3,692
|
public function buildTemplateAction ( ) { $ action = [ 'type' => ActionType :: POSTBACK , 'label' => $ this -> label , 'data' => $ this -> data , ] ; if ( isset ( $ this -> displayText ) ) { $ action [ 'displayText' ] = $ this -> displayText ; } return $ action ; }
|
Builds postback action structure .
|
3,693
|
public function build ( ) { if ( ! empty ( $ this -> container ) ) { return $ this -> container ; } $ contents = array_map ( function ( $ containerBuilder ) { return $ containerBuilder -> build ( ) ; } , $ this -> containerBuilders ) ; $ this -> container = [ 'type' => ContainerType :: CAROUSEL , 'contents' => $ contents , ] ; return $ this -> container ; }
|
Builds carousel container structure .
|
3,694
|
public static function create ( array $ associativeArray ) : Subscription { if ( array_key_exists ( 'keys' , $ associativeArray ) && is_array ( $ associativeArray [ 'keys' ] ) ) { return new self ( $ associativeArray [ 'endpoint' ] , $ associativeArray [ 'keys' ] [ 'p256dh' ] ?? null , $ associativeArray [ 'keys' ] [ 'auth' ] ?? null , $ associativeArray [ 'contentEncoding' ] ?? "aesgcm" ) ; } if ( array_key_exists ( 'publicKey' , $ associativeArray ) || array_key_exists ( 'authToken' , $ associativeArray ) || array_key_exists ( 'contentEncoding' , $ associativeArray ) ) { return new self ( $ associativeArray [ 'endpoint' ] , $ associativeArray [ 'publicKey' ] ?? null , $ associativeArray [ 'authToken' ] ?? null , $ associativeArray [ 'contentEncoding' ] ?? "aesgcm" ) ; } return new self ( $ associativeArray [ 'endpoint' ] ) ; }
|
Subscription factory .
|
3,695
|
public static function getVapidHeaders ( string $ audience , string $ subject , string $ publicKey , string $ privateKey , string $ contentEncoding , ? int $ expiration = null ) { $ expirationLimit = time ( ) + 43200 ; if ( null === $ expiration || $ expiration > $ expirationLimit ) { $ expiration = $ expirationLimit ; } $ header = [ 'typ' => 'JWT' , 'alg' => 'ES256' , ] ; $ jwtPayload = json_encode ( [ 'aud' => $ audience , 'exp' => $ expiration , 'sub' => $ subject , ] , JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK ) ; if ( ! $ jwtPayload ) { throw new \ ErrorException ( 'Failed to encode JWT payload in JSON' ) ; } list ( $ x , $ y ) = Utils :: unserializePublicKey ( $ publicKey ) ; $ jwk = JWK :: create ( [ 'kty' => 'EC' , 'crv' => 'P-256' , 'x' => Base64Url :: encode ( $ x ) , 'y' => Base64Url :: encode ( $ y ) , 'd' => Base64Url :: encode ( $ privateKey ) , ] ) ; $ jsonConverter = new StandardConverter ( ) ; $ jwsCompactSerializer = new CompactSerializer ( $ jsonConverter ) ; $ jwsBuilder = new JWSBuilder ( $ jsonConverter , AlgorithmManager :: create ( [ new ES256 ( ) ] ) ) ; $ jws = $ jwsBuilder -> create ( ) -> withPayload ( $ jwtPayload ) -> addSignature ( $ jwk , $ header ) -> build ( ) ; $ jwt = $ jwsCompactSerializer -> serialize ( $ jws , 0 ) ; $ encodedPublicKey = Base64Url :: encode ( $ publicKey ) ; if ( $ contentEncoding === "aesgcm" ) { return [ 'Authorization' => 'WebPush ' . $ jwt , 'Crypto-Key' => 'p256ecdsa=' . $ encodedPublicKey , ] ; } elseif ( $ contentEncoding === 'aes128gcm' ) { return [ 'Authorization' => 'vapid t=' . $ jwt . ', k=' . $ encodedPublicKey , ] ; } throw new \ ErrorException ( 'This content encoding is not supported' ) ; }
|
This method takes the required VAPID parameters and returns the required header to be added to a Web Push Protocol Request .
|
3,696
|
public static function createVapidKeys ( ) : array { $ curve = NistCurve :: curve256 ( ) ; $ privateKey = $ curve -> createPrivateKey ( ) ; $ publicKey = $ curve -> createPublicKey ( $ privateKey ) ; $ binaryPublicKey = hex2bin ( Utils :: serializePublicKey ( $ publicKey ) ) ; if ( ! $ binaryPublicKey ) { throw new \ ErrorException ( 'Failed to convert VAPID public key from hexadecimal to binary' ) ; } $ binaryPrivateKey = hex2bin ( str_pad ( gmp_strval ( $ privateKey -> getSecret ( ) , 16 ) , 2 * self :: PRIVATE_KEY_LENGTH , '0' , STR_PAD_LEFT ) ) ; if ( ! $ binaryPrivateKey ) { throw new \ ErrorException ( 'Failed to convert VAPID private key from hexadecimal to binary' ) ; } return [ 'publicKey' => Base64Url :: encode ( $ binaryPublicKey ) , 'privateKey' => Base64Url :: encode ( $ binaryPrivateKey ) ] ; }
|
This method creates VAPID keys in case you would not be able to have a Linux bash . DO NOT create keys at each initialization! Save those keys and reuse them .
|
3,697
|
public function flush ( ? int $ batchSize = null ) : \ Generator { if ( null === $ this -> notifications || empty ( $ this -> notifications ) ) { yield from [ ] ; return ; } if ( null === $ batchSize ) { $ batchSize = $ this -> defaultOptions [ 'batchSize' ] ; } $ batches = array_chunk ( $ this -> notifications , $ batchSize ) ; $ this -> notifications = [ ] ; foreach ( $ batches as $ batch ) { $ requests = $ this -> prepare ( $ batch ) ; $ promises = [ ] ; foreach ( $ requests as $ request ) { $ promises [ ] = $ this -> client -> sendAsync ( $ request ) -> then ( function ( $ response ) use ( $ request ) { return new MessageSentReport ( $ request , $ response ) ; } ) -> otherwise ( function ( $ reason ) { return new MessageSentReport ( $ reason -> getRequest ( ) , $ reason -> getResponse ( ) , false , $ reason -> getMessage ( ) ) ; } ) ; } foreach ( $ promises as $ promise ) { yield $ promise -> wait ( ) ; } } if ( $ this -> reuseVAPIDHeaders ) { $ this -> vapidHeaders = [ ] ; } }
|
Flush notifications . Triggers the requests .
|
3,698
|
protected function createRelationshipFunction ( & $ stub , $ relationshipName , $ relationshipType , $ argsString ) { $ tabIndent = ' ' ; $ code = "public function " . $ relationshipName . "()\n" . $ tabIndent . "{\n" . $ tabIndent . $ tabIndent . "return \$this->" . $ relationshipType . "(" . $ argsString . ");" . "\n" . $ tabIndent . "}" ; $ str = '{{relationships}}' ; $ stub = str_replace ( $ str , $ code . "\n" . $ tabIndent . $ str , $ stub ) ; return $ this ; }
|
Create the code for a model relationship
|
3,699
|
protected function processJSONForeignKeys ( $ file ) { $ json = File :: get ( $ file ) ; $ fields = json_decode ( $ json ) ; if ( ! property_exists ( $ fields , 'foreign_keys' ) ) { return '' ; } $ foreignKeysString = '' ; foreach ( $ fields -> foreign_keys as $ foreign_key ) { $ foreignKeysString .= $ foreign_key -> column . '#' . $ foreign_key -> references . '#' . $ foreign_key -> on ; if ( property_exists ( $ foreign_key , 'onDelete' ) ) { $ foreignKeysString .= '#' . $ foreign_key -> onDelete ; } if ( property_exists ( $ foreign_key , 'onUpdate' ) ) { $ foreignKeysString .= '#' . $ foreign_key -> onUpdate ; } $ foreignKeysString .= ',' ; } $ foreignKeysString = rtrim ( $ foreignKeysString , ',' ) ; return $ foreignKeysString ; }
|
Process the JSON Foreign keys .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.