idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
13,200
public function get ( $ className , array $ objectData ) { $ this -> runningProcesses ++ ; try { $ result = $ this -> convertToObject ( $ className , $ objectData ) ; $ this -> runningProcesses -- ; return $ result ; } catch ( \ Exception $ exception ) { $ this -> runningProcesses -- ; throw $ exception ; } }
Returns an instance of the given configuration object name . The object is recursively filled with the given array data .
13,201
protected function register ( $ className ) { if ( false === isset ( $ this -> configurationObjectServiceFactory [ $ className ] ) ) { if ( false === Core :: get ( ) -> classExists ( $ className ) ) { throw new ClassNotFoundException ( 'Trying to get a non-existing configuration object: "' . $ className . '".' , 1448886437 ) ; } if ( false === in_array ( ConfigurationObjectInterface :: class , class_implements ( $ className ) ) ) { throw new WrongInheritanceException ( 'The configuration object class: "' . $ className . '" must implement "' . ConfigurationObjectInterface :: class . '".' , 1448886449 ) ; } $ configurationObjectClassName = $ className ; $ serviceFactory = $ configurationObjectClassName :: getConfigurationObjectServices ( ) ; if ( false === $ serviceFactory instanceof ServiceFactory ) { throw new WrongServiceException ( 'Service factory for configuration object class: "' . $ className . '" must be an instance of "' . ServiceFactory :: class . '".' , 1448886479 ) ; } $ serviceFactory -> initialize ( ) ; $ this -> configurationObjectServiceFactory [ $ className ] = $ serviceFactory ; } return $ this -> configurationObjectServiceFactory [ $ className ] ; }
Any configuration object needs to be registered before it can be used .
13,202
public function createAllDocumentTables ( ) { foreach ( $ this -> metadataFactory -> getAllMetadata ( ) as $ class ) { if ( $ class -> isMappedSuperclass || $ class -> isEmbeddedDocument || ( count ( $ class -> parentClassNames ) && $ class -> inheritanceType == ClassMetadata :: INHERITANCE_TYPE_SINGLE_TABLE ) ) { continue ; } $ this -> createDocumentTableFor ( $ class -> name ) ; } }
Create all the mapped document tables in the metadata factory .
13,203
public function createDocumentTableFor ( $ documentName ) { $ class = $ this -> dm -> getClassMetadata ( $ documentName ) ; if ( $ class -> isMappedSuperclass || $ class -> isEmbeddedDocument ) { throw ODMException :: cannotCreateMappedSuperclassTable ( $ documentName ) ; } $ this -> doCreateTable ( $ class -> getTableName ( ) , $ class -> getDefinitionTable ( ) ) ; }
Checks if the DynamoDB table for a mapped class exists and if not creates it .
13,204
public function deleteAllDocumentTables ( ) { foreach ( $ this -> metadataFactory -> getAllMetadata ( ) as $ class ) { if ( $ class -> isMappedSuperclass || $ class -> isEmbeddedDocument || ( count ( $ class -> parentClassNames ) && $ class -> inheritanceType == ClassMetadata :: INHERITANCE_TYPE_SINGLE_TABLE ) ) { continue ; } $ this -> deleteDocumentTableFor ( $ class -> name ) ; } }
Delete all tables for document classes known to DynamoDM .
13,205
public function deleteDocumentTableFor ( $ documentName ) { $ class = $ this -> dm -> getClassMetadata ( $ documentName ) ; if ( $ class -> isMappedSuperclass || $ class -> isEmbeddedDocument ) { throw ODMException :: cannotDeleteMappedSuperclassTable ( $ documentName ) ; } $ this -> doDeleteTable ( $ class -> getTableName ( ) , $ class -> getDefinitionTable ( ) ) ; }
Checks if the DynamoDB table for a mapped class exists and deletes it if it does .
13,206
public function rebuildDocumentTableFor ( $ documentName ) { $ class = $ this -> dm -> getClassMetadata ( $ documentName ) ; $ table = $ class -> getTableName ( ) ; $ defintiion = $ class -> getDefinitionTable ( ) ; $ this -> doDeleteTable ( $ table , $ defintiion ) ; $ this -> doCreateTable ( $ table , $ defintiion ) ; }
Deletes and rebuilds the DynamoDB table for a mapped class .
13,207
private function LayoutCondition ( ) { $ sql = Access :: SqlBuilder ( ) ; $ tbl = Area :: Schema ( ) -> Table ( ) ; return $ sql -> Equals ( $ tbl -> Field ( 'Layout' ) , $ sql -> Value ( $ this -> layout -> GetID ( ) ) ) ; }
Gets the layout condition for the name validator
13,208
public function subscribe ( $ eventType , $ callback ) { $ callback = $ this -> makeEventCallback ( $ callback ) ; if ( ! isset ( $ this -> eventList [ $ eventType ] ) || ! is_array ( $ this -> eventList [ $ eventType ] ) ) { $ this -> eventList [ $ eventType ] = [ ] ; } array_push ( $ this -> eventList [ $ eventType ] , $ callback ) ; return $ callback [ 'id' ] ; }
Add a callback on a specific backend event .
13,209
public function unsubscribe ( $ eventType , $ callbackId ) { $ success = false ; if ( ! isset ( $ this -> eventList [ $ eventType ] ) || ! is_array ( $ this -> eventList [ $ eventType ] ) ) { $ this -> eventList [ $ eventType ] = array_filter ( $ this -> eventList [ $ eventType ] , function ( $ cb ) use ( $ callbackId ) { return $ cb [ 'id' ] !== $ callbackId ; } ) ; $ success = true ; } return $ success ; }
Remove callback by identifier .
13,210
public function permAssign ( $ permid , $ permvalue , $ permnegated = false , $ permskip = false ) { return $ this -> getParent ( ) -> serverGroupPermAssign ( $ this -> getId ( ) , $ permid , $ permvalue , $ permnegated , $ permskip ) ; }
Adds a set of specified permissions to the server group . Multiple permissions can be added by providing the four parameters of each permission in separate arrays .
13,211
private function getParentId ( $ item , $ key ) { if ( is_array ( $ item ) ) { $ result = $ item [ $ key ] ; } elseif ( $ item instanceof \ Praxigento \ Core \ Data ) { $ result = $ item -> get ( $ key ) ; } else { $ result = $ item ; } return $ result ; }
Get Parent ID from entry . Entry can be integer array or Data Object .
13,212
public function isLevelEnabled ( string $ level , int $ level_num = null ) { if ( $ level_num === null ) $ level_num = Logger :: getLevelNumeric ( $ level ) ; return $ level_num >= $ this -> min_level ; }
Return if a message of a specific level would be accepted
13,213
protected function getAllMetadata ( $ managerName = null ) { if ( ! $ this -> allMetadata ) { $ this -> allMetadata = $ this -> registry -> getManager ( $ managerName ) -> getMetadataFactory ( ) -> getAllMetadata ( ) ; } return $ this -> allMetadata ; }
Returns all management class metadata
13,214
private function isBaeEnv ( ) { if ( isset ( $ _SERVER [ 'HTTP_HOST' ] ) ) { $ host = $ _SERVER [ 'HTTP_HOST' ] ; $ pos = strpos ( $ host , '.' ) ; if ( $ pos !== false ) { $ substr = substr ( $ host , $ pos + 1 ) ; if ( $ substr == 'duapp.com' ) { return true ; } } } if ( isset ( $ _SERVER [ "HTTP_BAE_LOGID" ] ) ) { return true ; } return false ; }
is the environment BAE?
13,215
public function getEnvironment ( ) { $ environment_file = $ this -> resolvePath ( 'config/environment' ) ; if ( file_exists ( $ environment_file ) ) { $ environment = trim ( file_get_contents ( $ environment_file ) ) ; } else { $ environment = 'local' ; } return $ environment ; }
What environment are we running in? Local? Development? Production?
13,216
public function getBaseUrl ( $ include_script_name = false ) { $ this -> config -> load ( 'config' ) ; $ base_url = $ this -> config -> get ( 'base_url' ) ; if ( empty ( $ base_url ) ) { $ protocol = 'http://' ; if ( array_key_exists ( 'HTTPS' , $ _SERVER ) && strtolower ( $ _SERVER [ 'HTTPS' ] ) == 'on' ) { $ protocol = 'https://' ; } $ base_url = $ protocol . $ _SERVER [ 'SERVER_NAME' ] . dirname ( $ _SERVER [ 'SCRIPT_NAME' ] ) ; } $ base_url = rtrim ( $ base_url , '/' ) . '/' ; if ( $ include_script_name ) { return $ base_url . basename ( $ _SERVER [ 'SCRIPT_NAME' ] ) ; } else { return $ base_url ; } }
Get the the base url of our app
13,217
private function determine ( ) { if ( false !== $ this -> filepath && true === is_readable ( $ this -> filepath . '/' . $ this -> filename ) ) { return strtolower ( trim ( file_get_contents ( $ this -> filepath . '/' . $ this -> filename ) ) ) ; } elseif ( null !== getenv ( $ this -> variable ) ) { return getenv ( $ this -> variable ) ; } else { return false ; } }
Dertermines the runtime environment by checking for a file or an environment variable containing the applications runtime environment name . If both checks fail it will return false .
13,218
public static function installLegacySymlinks ( Event $ event ) : void { $ options = static :: getOptions ( $ event ) ; $ consoleDir = static :: getConsoleDir ( $ event , 'install legacy symlinks' ) ; static :: executeCommand ( $ event , $ consoleDir , 'ngsite:symlink:legacy' , $ options [ 'process-timeout' ] ) ; }
Symlinks legacy siteaccesses and various other legacy files to their proper locations .
13,219
protected function createInstance ( \ ReflectionClass $ reflectedClass ) { $ constructor = $ reflectedClass -> getConstructor ( ) ; if ( $ constructor && $ constructor -> getNumberOfRequiredParameters ( ) > 0 ) { throw new \ RuntimeException ( 'Unable to hydrate an object requiring constructor param' ) ; } return $ reflectedClass -> newInstance ( ) ; }
Create an instance from a Reflected class
13,220
protected function normalize ( $ data ) { if ( null === $ data || is_scalar ( $ data ) ) { return $ data ; } if ( is_array ( $ data ) ) { foreach ( $ data as $ key => $ val ) { $ data [ $ key ] = $ this -> normalize ( $ val ) ; } return $ data ; } throw new \ RuntimeException ( 'An unexpected value could not be normalized: ' . var_export ( $ data , true ) ) ; }
Normalize php data for mongo
13,221
protected function serializeEmbeddedCollection ( MapperInterface $ mapper , array $ collection ) { $ data = array ( ) ; foreach ( $ collection as $ object ) { $ data [ ] = $ mapper -> serialize ( $ object ) ; } return $ data ; }
Serialize an embedded collection
13,222
protected function unserializeEmbeddedCollection ( MapperInterface $ mapper , array $ data ) { $ collection = array ( ) ; foreach ( $ data as $ document ) { $ collection [ ] = $ mapper -> unserialize ( $ document ) ; } return $ collection ; }
Unserialize an embedded collection
13,223
public function register ( ContainerInterface $ container ) { if ( ! isset ( $ container [ 'session' ] ) ) { $ container [ 'session' ] = function ( ContainerInterface $ container ) { return new Session ; } ; } if ( ! isset ( $ container [ 'router' ] ) ) { $ container [ 'router' ] = function ( ContainerInterface $ container ) { $ routerCacheFile = false ; if ( isset ( $ container -> get ( 'settings' ) [ 'routerCacheFile' ] ) ) { $ routerCacheFile = $ container -> get ( 'settings' ) [ 'routerCacheFile' ] ; } $ router = ( new Router ) -> setCacheFile ( $ routerCacheFile ) ; if ( method_exists ( $ router , 'setContainer' ) ) { $ router -> setContainer ( $ container ) ; } if ( method_exists ( $ router , 'setCallableResolver' ) ) { $ router -> setCallableResolver ( $ container [ 'callableResolver' ] ) ; } return $ router ; } ; } }
Register Mbh s default services .
13,224
private function AddModuleTypeOption ( Select $ select , $ type ) { if ( $ type != 'BuiltIn-Container' || ( ! Request :: GetData ( 'container' ) && Container :: Schema ( ) -> Count ( ) > 0 ) ) { $ select -> AddOption ( $ type , Trans ( $ type ) ) ; } }
Adds the module type option if allowed
13,225
public function warn ( $ msg ) { $ this -> mailMessage ( self :: LEVEL_WARN , $ msg ) ; if ( $ this -> checkLevel ( $ this -> loglevels , self :: LEVEL_WARN ) !== true ) return ; $ this -> writeMessage ( self :: LEVEL_WARN , $ msg ) ; }
Logs a warning
13,226
public function info ( $ msg ) { $ this -> mailMessage ( self :: LEVEL_INFO , $ msg ) ; if ( $ this -> checkLevel ( $ this -> loglevels , self :: LEVEL_INFO ) !== true ) return ; $ this -> writeMessage ( self :: LEVEL_INFO , $ msg ) ; }
Logs an information
13,227
public function createStringClassSnapshotHash ( ) { $ hash = null ; foreach ( $ this as $ property => $ value ) { $ hash = md5 ( $ hash . $ property . '=' . $ value ) ; } return $ hash ; }
Create hash string from current class properties and itself values . This method is good stuff for caching dynamic instances
13,228
public function getMethodRequiredArgCount ( $ class , string $ method ) : int { $ instance = new \ ReflectionMethod ( $ class , $ method ) ; $ count = 0 ; foreach ( $ instance -> getParameters ( ) as $ arg ) { if ( ! $ arg -> isOptional ( ) ) { $ count ++ ; } } return $ count ; }
Get method required arguments count
13,229
public function contains ( $ document ) { if ( ! is_object ( $ document ) ) { throw new \ InvalidArgumentException ( gettype ( $ document ) ) ; } return $ this -> unitOfWork -> isScheduledForInsert ( $ document ) || $ this -> unitOfWork -> isInIdentityMap ( $ document ) && ! $ this -> unitOfWork -> isScheduledForDelete ( $ document ) ; }
Determines whether a document instance is managed in this DocumentManager .
13,230
public function getFilterCollection ( ) { if ( null === $ this -> filterCollection ) { $ this -> filterCollection = new Filter \ FilterCollection ( $ this ) ; } return $ this -> filterCollection ; }
Gets the filter collection .
13,231
public function persist ( $ document ) { if ( ! is_object ( $ document ) ) { throw new \ InvalidArgumentException ( gettype ( $ document ) ) ; } $ this -> errorIfClosed ( ) ; $ this -> unitOfWork -> persist ( $ document ) ; }
Tells the DocumentManager to make an instance managed and persistent .
13,232
public function refresh ( $ document ) { if ( ! is_object ( $ document ) ) { throw new \ InvalidArgumentException ( gettype ( $ document ) ) ; } $ this -> errorIfClosed ( ) ; $ this -> unitOfWork -> refresh ( $ document ) ; }
Refreshes the persistent state of a document from the database overriding any local changes that have not yet been persisted .
13,233
public function remove ( $ document ) { if ( ! is_object ( $ document ) ) { throw new \ InvalidArgumentException ( gettype ( $ document ) ) ; } $ this -> errorIfClosed ( ) ; $ this -> unitOfWork -> remove ( $ document ) ; }
Removes a document instance .
13,234
public function addBrick ( $ postValues ) { $ brickObject = BrickFactory :: createBrickFromPostValues ( $ postValues ) ; $ bricks = $ this -> repository -> bricks ; $ bricks [ ] = $ brickObject ; $ this -> repository -> bricks = $ bricks ; $ this -> save ( ) ; }
Add a brick
13,235
public function getBrickBySlug ( $ slug ) { $ bricks = $ this -> repository -> bricks ; foreach ( $ bricks as $ brick ) { if ( $ brick -> slug == $ slug ) { return $ brick ; } } return null ; }
Get a brick by its slug
13,236
public function saveBrick ( $ slug , $ postValues ) { $ brickObject = BrickFactory :: createBrickFromPostValues ( $ postValues ) ; $ bricks = $ this -> repository -> bricks ; foreach ( $ bricks as $ key => $ brick ) { if ( $ brick -> slug == $ slug ) { $ bricks [ $ key ] = $ brickObject ; } } $ this -> repository -> bricks = $ bricks ; $ this -> save ( ) ; }
Save changes to a brick
13,237
public function deleteBrickBySlug ( $ slug ) { $ bricks = $ this -> repository -> bricks ; foreach ( $ bricks as $ key => $ brickObject ) { if ( $ brickObject -> slug == $ slug ) { unset ( $ bricks [ $ key ] ) ; } } $ bricks = array_values ( $ bricks ) ; $ this -> repository -> bricks = $ bricks ; $ this -> save ( ) ; }
Delete a brick by its slug
13,238
public static function toMap ( array $ array ) { $ map = new SimpleMap ( ) ; foreach ( $ array as $ k => $ v ) $ map -> put ( $ k , $ v ) ; return $ map ; }
Converts a PHP array into a Map .
13,239
public function skip ( int $ n ) : int { if ( $ n <= 0 ) { return 0 ; } $ skipped = 0 ; $ skipLimit = min ( self :: MAX_SKIP_BUFFER_SIZE , $ n ) ; while ( $ skipped < $ n ) { $ buf = $ this -> read ( min ( $ skipLimit , $ n - $ skipped ) ) ; if ( $ buf === null ) { break ; } $ skipped += strlen ( $ buf ) ; } return $ skipped ; }
Skips over and discards n bytes of data from this input stream .
13,240
public static function uuid ( $ version = self :: UUID_V4 ) { switch ( $ version ) { case self :: UUID_V4 : $ data = openssl_random_pseudo_bytes ( 16 ) ; $ data [ 6 ] = chr ( ord ( $ data [ 6 ] ) & 0x0f | 0x40 ) ; $ data [ 8 ] = chr ( ord ( $ data [ 8 ] ) & 0x3f | 0x80 ) ; return vsprintf ( '%s%s-%s-%s-%s-%s%s%s' , str_split ( bin2hex ( $ data ) , 4 ) ) ; default : throw new Exception ( "Invalid or unknown uuid version specified" ) ; } }
Generate a uuid according to a specific UUID definition
13,241
public function toUser ( $ token = false ) { $ payload = $ this -> getPayload ( $ token ) ; if ( ! $ user = $ this -> user -> getBy ( $ this -> identifier , $ payload [ 'sub' ] ) ) { return false ; } return $ user ; }
Find a user using the user identifier in the subject claim .
13,242
public function fromUser ( $ user , array $ customClaims = [ ] ) { $ payload = $ this -> makePayload ( $ user -> { $ this -> identifier } , $ customClaims ) ; return $ this -> manager -> encode ( $ payload ) -> get ( ) ; }
Generate a token using the user identifier as the subject claim .
13,243
public function authenticate ( $ token = false ) { $ id = $ this -> getPayload ( $ token ) -> get ( 'sub' ) ; if ( ! $ this -> auth -> byId ( $ id ) ) { return false ; } return $ this -> auth -> user ( ) ; }
Authenticate a user via a token .
13,244
public function getPayload ( $ token = false ) { $ this -> requireToken ( $ token ) ; return $ this -> manager -> decode ( $ this -> token ) ; }
Get the raw Payload instance .
13,245
public function parseToken ( $ method = 'bearer' , $ header = 'authorization' , $ query = 'token' ) { if ( ! $ token = $ this -> parseAuthHeader ( $ header , $ method ) ) { if ( ! $ token = $ this -> request -> { $ query } ) { if ( ! $ token = $ this -> request -> header ( 'Token' ) ) { throw new JWTException ( 'The token could not be parsed from the request' , 400 ) ; } } } return $ this -> setToken ( $ token ) ; }
Parse the token from the request .
13,246
protected function parseAuthHeader ( $ header = 'authorization' , $ method = 'bearer' ) { $ header = $ this -> request -> headers -> get ( $ header ) ; if ( ! starts_with ( strtolower ( $ header ) , $ method ) ) { return false ; } return trim ( str_ireplace ( $ method , '' , $ header ) ) ; }
Parse token from the authorization header .
13,247
protected function requireToken ( $ token ) { if ( $ token ) { return $ this -> setToken ( $ token ) ; } elseif ( $ this -> token ) { return $ this ; } else { throw new JWTException ( 'A token is required' , 400 ) ; } }
Ensure that a token is available .
13,248
public function add ( ProviderInterface $ provider ) { $ container = $ this -> container ; $ this -> container = $ provider -> register ( $ container ) ; $ this -> providers [ ] = ( string ) get_class ( $ provider ) ; return $ this ; }
Adds a new provider to be registered .
13,249
public function config ( $ data ) { $ items = is_array ( $ data ) ? $ data : array ( ) ; $ config = new Provider \ Configuration ( $ items ) ; if ( is_string ( $ data ) ) { $ config -> load ( $ data ) ; } $ interface = ProviderInterface :: CONFIG ; return $ this -> set ( $ interface , $ config ) ; }
Creates a new configuration based on given data .
13,250
public function emit ( ResponseInterface $ response ) { $ code = $ response -> code ( ) . ' ' . $ response -> reason ( ) ; $ headers = $ response -> headers ( ) ; $ version = $ response -> version ( ) ; foreach ( $ headers as $ name => $ values ) { header ( $ name . ': ' . implode ( ',' , $ values ) ) ; } header ( sprintf ( 'HTTP/%s %s' , $ version , $ code ) ) ; return $ response ; }
Emits the headers from the response instance .
13,251
public function handle ( RequestInterface $ request ) { $ handler = new RoutingHandler ( $ this -> container ) ; if ( ! $ this -> has ( Application :: MIDDLEWARE ) ) { return $ handler -> handle ( $ request ) ; } $ dispatcher = $ this -> get ( Application :: MIDDLEWARE ) ; return $ dispatcher -> process ( $ request , $ handler ) ; }
Dispatches the request and returns into a response .
13,252
protected function cacheResults ( $ name , Closure $ callback ) { return Cache :: remember ( 'cache::' . $ name , $ this -> minutes , $ callback ) ; }
Cache the results .
13,253
public function getTransaction ( $ transaction = self :: TRANSACTION_LAST_USED , $ throwExceptionIfNotFound = true ) { if ( $ transaction === self :: TRANSACTIONS_ALL ) { return array_keys ( $ this -> queue ) ; } if ( $ transaction === self :: TRANSACTION_LAST_CREATED ) { if ( ! $ this -> queue ) { $ this -> newTransaction ( ) ; } $ queue = array_keys ( $ this -> queue ) ; return array_pop ( $ queue ) ; } if ( $ transaction === self :: TRANSACTION_LAST_USED ) { if ( ! $ this -> queue ) { $ this -> newTransaction ( ) ; } return $ this -> lastTransaction ; } if ( $ transaction === self :: TRANSACTION_NEW ) { return $ this -> newTransaction ( ) ; } if ( ! array_key_exists ( $ transaction , $ this -> queue ) ) { if ( $ throwExceptionIfNotFound ) { throw new TransactionDoesNotExistException ( "Transaction with this name `{$transaction}` doesn't exist. Sorry." ) ; } return null ; } return $ transaction ; }
Get a transaction name
13,254
public function removeTransaction ( $ transaction = self :: TRANSACTION_LAST_USED , $ throwExceptionIfNotFound = true ) { if ( $ transaction === self :: TRANSACTIONS_ALL ) { $ numTransactions = count ( $ this -> queue ) ; $ this -> queue = array ( ) ; $ this -> lastTransaction = null ; return $ numTransactions ; } if ( $ transaction === self :: TRANSACTION_LAST_CREATED ) { $ keys = array_keys ( $ this -> queue ) ; if ( $ transaction = array_pop ( $ keys ) ) { if ( $ this -> lastTransaction === $ transaction ) { $ this -> lastTransaction = null ; } unset ( $ this -> queue [ $ transaction ] ) ; return 1 ; } return 0 ; } if ( $ transaction === self :: TRANSACTION_LAST_USED ) { if ( $ this -> lastTransaction ) { unset ( $ this -> queue [ $ this -> lastTransaction ] ) ; $ this -> lastTransaction = null ; return 0 ; } return 0 ; } if ( is_array ( $ transaction ) ) { $ output = 0 ; foreach ( $ transaction as $ name ) { if ( array_key_exists ( $ name , $ this -> queue ) ) { if ( $ this -> lastTransaction === $ name ) { $ this -> lastTransaction = null ; } unset ( $ this -> queue [ $ name ] ) ; $ output ++ ; } elseif ( $ throwExceptionIfNotFound ) { throw new TransactionDoesNotExistException ( "Transaction with this name `{$name}` doesn't exist. Sorry." ) ; } } return $ output ; } if ( is_scalar ( $ transaction ) ) { if ( array_key_exists ( $ transaction , $ this -> queue ) ) { if ( $ this -> lastTransaction === $ transaction ) { $ this -> lastTransaction = null ; } unset ( $ this -> queue [ $ name ] ) ; return 1 ; } elseif ( $ throwExceptionIfNotFound ) { throw new TransactionDoesNotExistException ( "Transaction with this name `{$transaction}` doesn't exist. Sorry." ) ; } return 0 ; } throw new \ InvalidArgumentException ( sprintf ( "Not sure how to remove transaction `%s`" , print_r ( $ transaction , true ) ) ) ; }
Remove a transaction
13,255
public function send ( $ closure = null ) { if ( gettype ( $ closure ) == 'object' ) { call_user_func ( $ closure , $ this ) ; } foreach ( $ this -> viewmodels as $ type => $ view ) { if ( null !== $ view ) { $ viewmodel = new ViewModel ( $ view , false ) ; $ viewmodel -> assign ( $ this -> variables ) ; $ this -> message [ $ type ] = $ viewmodel -> render ( ) ; } } $ to = $ this -> formatTo ( ) ; $ headers = $ this -> formatHeaders ( ) ; $ message = $ this -> formatMessage ( ) ; @ mail ( $ to , $ this -> subject , $ message , $ headers ) ; if ( null === error_get_last ( ) ) { $ this -> send = true ; } return $ this ; }
Try to send the mail with optional callback .
13,256
public function addHeader ( $ key , $ value ) { if ( false === is_string ( $ key ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ key ) ) , E_USER_ERROR ) ; } if ( false === is_string ( $ value ) ) { return trigger_error ( sprintf ( 'Argument 2 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ value ) ) , E_USER_ERROR ) ; } if ( false === isset ( $ this -> headers [ 'custom' ] ) ) { $ this -> headers [ 'custom' ] = [ ] ; } $ this -> headers [ 'custom' ] [ $ key ] = $ value ; }
Adds a custom header to the mail
13,257
public function removeHeader ( $ key ) { if ( false === is_string ( $ key ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ key ) ) , E_USER_ERROR ) ; } if ( true === isset ( $ this -> headers [ 'custom' ] [ $ key ] ) ) { unset ( $ this -> headers [ 'custom' ] [ $ key ] ) ; } }
Removes a custom header by key
13,258
public function render ( $ htmlview = null , $ textview = null ) { if ( null !== $ htmlview && false === is_string ( $ htmlview ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ htmlview ) ) , E_USER_ERROR ) ; } if ( null !== $ textview && false === is_string ( $ textview ) ) { return trigger_error ( sprintf ( 'Argument 2 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ textview ) ) , E_USER_ERROR ) ; } $ this -> viewmodels = [ 'html' => $ htmlview , 'text' => $ textview ] ; return $ this ; }
Parses the message by given an optional HTML view and an optional plain text view
13,259
public function priority ( $ level = 1 ) { if ( false === ( '-' . intval ( $ level ) == '-' . $ level ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type integer, "%s" given' , __METHOD__ , gettype ( $ level ) ) , E_USER_ERROR ) ; } if ( $ level < 1 || $ level > 5 ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() should be between 1 and 5, "%s" given' , __METHOD__ , $ level ) , E_USER_ERROR ) ; } $ priorities = [ 1 => [ '1 (Highest)' , 'High' , 'High' ] , 2 => [ '2 (High)' , 'High' , 'High' ] , 3 => [ '3 (Normal)' , 'Normal' , 'Normal' ] , 4 => [ '4 (Low)' , 'Low' , 'Low' ] , 5 => [ '5 (Lowest)' , 'Low' , 'Low' ] , ] ; $ this -> headers [ 'priority' ] = $ priorities [ $ level ] ; return $ this ; }
Sets the priority Level between 1 and 5
13,260
public function to ( $ email , $ name = null ) { if ( false === $ this -> validateEmail ( $ email ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be a valid email' , __METHOD__ ) , E_USER_ERROR ) ; } if ( null !== $ name && false === is_string ( $ name ) ) { return trigger_error ( sprintf ( 'Argument 2 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ name ) ) , E_USER_ERROR ) ; } if ( false === isset ( $ this -> headers [ 'to' ] ) ) { $ this -> headers [ 'to' ] = [ ] ; } $ this -> headers [ 'to' ] [ ] = ( object ) [ 'email' => $ email , 'name' => $ name ] ; return $ this ; }
Adds to email
13,261
private function validateEmail ( $ email ) { if ( true === is_string ( $ email ) ) { return false !== filter_var ( trim ( $ email ) , \ FILTER_VALIDATE_EMAIL ) ; } return false ; }
Returns if a email is valid or not
13,262
private function emailsToString ( $ emails ) { $ format = [ ] ; foreach ( $ emails as $ email ) { if ( true === isset ( $ email -> name ) && trim ( $ email -> name ) !== '' ) { $ format [ ] = sprintf ( '"%s" <%s>' , $ email -> name , filter_var ( $ email -> email , FILTER_SANITIZE_EMAIL ) ) ; } else { $ format [ ] = filter_var ( $ email -> email , FILTER_SANITIZE_EMAIL ) ; } } $ emails = implode ( $ format , ',' ) ; return ( '' !== trim ( $ emails ) ) ? $ emails : null ; }
Formats an array with emails to string
13,263
private function formatTo ( ) { $ to = null ; if ( true === isset ( $ this -> headers [ 'to' ] ) ) { $ to = $ this -> emailsToString ( $ this -> headers [ 'to' ] ) ; } return $ to ; }
Formats the to email and returns it
13,264
private function formatHeaders ( ) { $ headers = [ ] ; $ files = true === isset ( $ this -> headers [ 'files' ] ) ? $ this -> headers [ 'files' ] : [ ] ; foreach ( [ 'BCC' , 'CC' , 'Reply-To' , 'From' ] as $ type ) { if ( true === isset ( $ this -> headers [ strtolower ( $ type ) ] ) ) { $ headers [ ] = sprintf ( "%s: %s\r\n" , $ type , $ this -> emailsToString ( $ this -> headers [ strtolower ( $ type ) ] ) ) ; } } if ( $ notify = $ this -> formatNotify ( ) ) { $ headers [ ] = sprintf ( "Disposition-Notification-To: %s\r\n" , $ notify ) ; $ headers [ ] = sprintf ( "X-Confirm-Reading-To: %s\r\n" , $ notify ) ; } if ( true === isset ( $ this -> headers [ 'priority' ] ) ) { $ headers [ ] = sprintf ( "X-Priority: %s\r\n" , $ this -> headers [ 'priority' ] [ 0 ] ) ; $ headers [ ] = sprintf ( "X-MSMail-Priority: %s\r\n" , $ this -> headers [ 'priority' ] [ 1 ] ) ; $ headers [ ] = sprintf ( "Importance: %s\r\n" , $ this -> headers [ 'priority' ] [ 2 ] ) ; } if ( true === isset ( $ this -> headers [ 'custom' ] ) ) { foreach ( $ this -> headers [ 'custom' ] as $ key => $ value ) { $ headers [ ] = sprintf ( "%s: %s\r\n" , $ key , $ value ) ; } } if ( count ( $ files ) > 0 ) { $ headers [ ] = sprintf ( "Content-Type: multipart/mixed; boundary=\"Boundary-mixed-%s\"\r\n" , $ this -> getBoundary ( ) ) ; } else { $ headers [ ] = sprintf ( "Content-Type: multipart/alternative; boundary=\"Boundary-alt-%s\"\r\n\r\n" , $ this -> getBoundary ( ) ) ; } return implode ( '' , $ headers ) ; }
Formats the headers and returns it as a string
13,265
private function formatMessage ( ) { $ message = [ ] ; $ files = true === isset ( $ this -> headers [ 'files' ] ) ? $ this -> headers [ 'files' ] : [ ] ; if ( count ( $ files ) > 0 ) { $ message [ ] = sprintf ( "--Boundary-mixed-%s\r\n" , $ this -> getBoundary ( ) ) ; $ message [ ] = sprintf ( "Content-Type: multipart/alternative; boundary=\"Boundary-alt-%s\"\r\n\r\n" , $ this -> getBoundary ( ) ) ; } if ( true === isset ( $ this -> message [ 'text' ] ) ) { $ message [ ] = sprintf ( "--Boundary-alt-%s\r\n" , $ this -> getBoundary ( ) ) ; $ message [ ] = "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n" ; $ message [ ] = "Content-Transfer-Encoding: 7bit\r\n\r\n" ; $ message [ ] = sprintf ( "%s\r\n\r\n" , $ this -> message [ 'text' ] ) ; } if ( true === isset ( $ this -> message [ 'html' ] ) ) { $ message [ ] = sprintf ( "--Boundary-alt-%s\r\n" , $ this -> getBoundary ( ) ) ; $ message [ ] = "Content-Type: text/html; charset=\"iso-8859-1\"\r\n" ; $ message [ ] = "Content-Transfer-Encoding: 7bit\r\n\r\n" ; $ message [ ] = sprintf ( "%s\r\n\r\n" , $ this -> message [ 'html' ] ) ; } $ message [ ] = sprintf ( "--Boundary-alt-%s--\r\n\r\n" , $ this -> getBoundary ( ) ) ; if ( count ( $ files ) > 0 ) { foreach ( $ files as $ attachment ) { $ stream = fopen ( $ attachment -> file -> entity ( ) -> getBasepath ( ) , 'rb' ) ; $ data = fread ( $ stream , $ attachment -> file -> getFilesize ( ) ) ; $ data = chunk_split ( base64_encode ( $ data ) ) ; $ message [ ] = sprintf ( "--Boundary-mixed-%s\r\n" , $ this -> getBoundary ( ) ) ; $ message [ ] = sprintf ( "Content-Type: %s; name=\"%s\"\r\n" , $ attachment -> mime , $ attachment -> name ) ; $ message [ ] = "Content-Transfer-Encoding: base64\r\n" ; $ message [ ] = "Content-Disposition: attachment \r\n\r\n" ; $ message [ ] = sprintf ( "%s\r\n" , $ data ) ; } $ message [ ] = sprintf ( "--Boundary-mixed-%s--\r\n" , $ this -> getBoundary ( ) ) ; } return implode ( '' , $ message ) ; }
Formats the messages and returns it as a string
13,266
private function formatNotify ( ) { $ notify = null ; if ( true === isset ( $ this -> headers [ 'notify' ] ) ) { $ notify = $ this -> emailsToString ( $ this -> headers [ 'notify' ] ) ; if ( null === $ notify ) { if ( true === isset ( $ this -> headers [ 'from' ] ) ) { $ notify = $ this -> emailsToString ( $ this -> headers [ 'from' ] ) ; } else { $ notify = ini_get ( 'sendmail_from' ) ; } } } return $ notify ; }
Formats the notify email and returns it
13,267
private function getBoundary ( ) { if ( null === $ this -> boundary ) { $ this -> boundary = md5 ( date ( 'r' , time ( ) ) ) ; } return $ this -> boundary ; }
Generates if needed and returns the boundary
13,268
public function format ( ) { $ string = '' ; if ( ! empty ( $ this -> segments ) ) { $ string = implode ( $ this -> separator , $ this -> segments ) ; } return $ string ; }
Returns the path as a string
13,269
public function parse ( $ path ) { if ( is_string ( $ path ) ) { if ( substr ( $ path , 0 , 1 ) === $ this -> separator ) { $ path = substr ( $ path , 1 ) ; } $ this -> segments = explode ( $ this -> separator , $ path ) ; } else { throw new \ InvalidArgumentException ( __METHOD__ . "() expects parameter one, path, to be a string" ) ; } return ; }
Parses the string path into this Path object
13,270
public function slice ( $ offset , $ length = null ) { if ( is_numeric ( $ offset ) && is_int ( + $ offset ) ) { if ( $ length === null || ( is_numeric ( $ length ) && is_int ( + $ length ) ) ) { $ this -> segments = array_slice ( $ this -> segments , $ offset , $ length ) ; } else { throw new \ InvalidArgumentException ( __METHOD__ . "() expects parameter two, length, to be null or an integer" ) ; } } else { throw new \ InvalidArgumentException ( __METHOD__ . "() expects parameter one, offset, to be an integer" ) ; } return $ this ; }
Slices the path
13,271
public function array_out ( $ key = null ) { if ( count ( $ this -> output ) < 2 || ( $ key && ! isset ( $ this -> output [ $ key ] ) ) ) { return array ( ) ; } if ( $ key ) { return $ this -> output [ $ key ] ; } array_shift ( $ this -> output ) ; return $ this -> output ; }
Return output dump as array
13,272
public function out ( $ key = null ) { if ( $ this -> options [ 'mode' ] == 'Html' ) { \ alkemann \ hl \ debug \ util \ adapters \ Html :: top ( $ this -> output , $ key ) ; return ; } $ this -> __out ( $ key ) ; }
Echo out stored debugging
13,273
public function defines ( ) { $ defines = get_defined_constants ( ) ; $ ret = array ( ) ; $ offset = - 1 ; while ( $ def = array_slice ( $ defines , $ offset -- , 1 ) ) { $ key = key ( $ def ) ; $ value = current ( $ def ) ; if ( $ key == 'FIRST_APP_CONSTANT' ) break ; $ ret [ $ key ] = $ value ; } return $ ret ; }
Grab global defines will start at FIRST_APP_CONSTANT if defined
13,274
public function dump_it ( $ var ) { $ adapter = '\alkemann\hl\debug\util\adapters\\' . $ this -> options [ 'mode' ] ; if ( is_array ( $ var ) ) return $ adapter :: dump_array ( $ var , $ this ) ; elseif ( is_object ( $ var ) ) return $ adapter :: dump_object ( $ var , $ this ) ; else return $ adapter :: dump_other ( $ var ) ; }
Send a variable to the adapter and return it s formated output
13,275
public function location ( $ trace ) { $ root = substr ( $ _SERVER [ 'DOCUMENT_ROOT' ] , 0 , strlen ( static :: $ defaults [ 'docroot' ] ) * - 1 ) ; $ file = implode ( '/' , array_diff ( explode ( '/' , $ trace [ 0 ] [ 'file' ] ) , explode ( '/' , $ root ) ) ) ; $ ret = array ( 'file' => $ file , 'line' => $ trace [ 0 ] [ 'line' ] ) ; if ( isset ( $ trace [ 1 ] [ 'function' ] ) ) $ ret [ 'function' ] = $ trace [ 1 ] [ 'function' ] ; if ( isset ( $ trace [ 1 ] [ 'class' ] ) ) $ ret [ 'class' ] = $ trace [ 1 ] [ 'class' ] ; return $ ret ; }
Create an array that describes the location of the debug call
13,276
public function hasRole ( $ name ) { if ( $ this -> RoleID ) { $ role = new Role ( $ this -> RoleID ) ; if ( $ role -> RoleName == $ name ) { return true ; } } foreach ( $ this -> Roles as $ role ) { if ( $ role -> RoleName == $ name ) { return true ; } } return false ; }
Checks if user has a specific role
13,277
public function getAttributeValue ( $ document , $ attribute ) { if ( $ document instanceof Proxy && ! in_array ( $ attribute , $ this -> getIdentifierAttributeNames ( ) ) && ! $ document -> __isInitialized ( ) ) { $ document -> __load ( ) ; } return $ this -> getPropertyMetadata ( $ attribute ) -> getValue ( $ document ) ; }
Gets the specified attribute s value off the given document .
13,278
public function getDefinitionTable ( ) { $ definition = array_merge ( $ this -> getIndex ( ) -> getDefinition ( ) , $ this -> getDefinitionSecondaryIndexes ( ) ) ; $ definition [ 'TableName' ] = $ this -> getTableName ( ) ; $ definition [ 'AttributeDefinitions' ] = $ this -> getDefinitionIndexAttributes ( ) ; return $ definition ; }
Return the table definition for this class formatted for AWS SDK .
13,279
public function getPropertyMetadata ( $ propertyName ) { if ( ! isset ( $ this -> propertyMetadata [ $ propertyName ] ) ) { throw MappingException :: mappingNotFound ( $ this -> name , $ propertyName ) ; } return $ this -> propertyMetadata [ $ propertyName ] ; }
Gets the mapping metadata of a property .
13,280
public function getTypeOfAttribute ( $ attributeName ) { return isset ( $ this -> propertyMetadata [ $ attributeName ] ) ? $ this -> propertyMetadata [ $ attributeName ] -> type : null ; }
Returns a type name of this attribute .
13,281
public function registerAlsoLoadMethod ( $ method , $ attributes ) { $ this -> alsoLoadMethods [ $ method ] = is_array ( $ attributes ) ? $ attributes : [ $ attributes ] ; }
Registers a method for loading document data before attribute hydration .
13,282
public function setDiscriminatorAttribute ( $ discriminatorAttribute ) { if ( $ discriminatorAttribute === null ) { $ this -> discriminatorAttribute = null ; return ; } foreach ( $ this -> propertyMetadata as $ attributeMapping ) { if ( $ discriminatorAttribute === $ attributeMapping -> attributeName ) { throw MappingException :: discriminatorAttributeConflict ( $ this -> name , $ discriminatorAttribute ) ; } } $ this -> discriminatorAttribute = $ discriminatorAttribute ; }
Sets the discriminator attribute .
13,283
public function setDiscriminatorDefaultValue ( $ discriminatorDefaultValue ) { if ( $ discriminatorDefaultValue !== null && ! array_key_exists ( $ discriminatorDefaultValue , $ this -> discriminatorMap ) ) { throw MappingException :: invalidDiscriminatorValue ( $ discriminatorDefaultValue , $ this -> name ) ; } $ this -> discriminatorDefaultValue = $ discriminatorDefaultValue ; }
Sets the default discriminator value to be used for this class Used for JOINED and SINGLE_TABLE inheritance mapping strategies if the document has no discriminator value
13,284
public function setTable ( $ table ) { if ( is_array ( $ table ) ) { if ( ! isset ( $ table [ 'name' ] ) ) { throw new \ InvalidArgumentException ( 'A name key is required when passing an array to setTable()' ) ; } $ this -> table = $ table [ 'name' ] ; } else { $ this -> table = $ table ; } }
Sets the table this document is mapped to .
13,285
public function run ( ) { foreach ( $ this -> getSteps ( ) as $ step ) { $ this -> logger -> info ( 'Starting "' . $ step -> getTitle ( ) . '"' ) ; foreach ( $ this -> getServersForStep ( $ step ) as $ server ) { if ( $ step -> isMandatory ( ) ) { $ server -> runCommands ( ) ; $ this -> logger -> info ( 'Finished "' . $ step -> getTitle ( ) . '" on "' . $ server -> getTitle ( ) . '"' ) ; } else { try { $ server -> runCommands ( ) ; $ this -> logger -> info ( 'Finished "' . $ step -> getTitle ( ) . '" on "' . $ server -> getTitle ( ) . '"' ) ; } catch ( \ Exception $ e ) { $ this -> logger -> info ( 'Failed to run "' . $ step -> getTitle ( ) . '" on "' . $ server -> getTitle ( ) . '"' ) ; } } } } }
Run commands on every server of every step with steps commands .
13,286
protected function parseSegments ( $ expression , $ requiredSegmentCount ) { $ segments = explode ( ',' , preg_replace ( "/[ \(\)\\\"\']/" , '' , $ expression ) ) ; if ( $ requiredSegmentCount > count ( $ segments ) ) throw new FrameworkException ( "Blade directive is short the required number of segments of " . $ requiredSegmentCount ) ; return $ segments ; }
Parses out a blade directive arguments
13,287
private function getFieldIndex ( $ prevTag , $ tag , $ fieldIndex ) { if ( $ prevTag == $ tag or '' == $ prevTag ) { return $ fieldIndex ; } $ specTag = $ this -> currentSpec [ 'field' ] -> getTag ( ) ; if ( preg_match ( '/' . $ specTag . '/' , $ tag ) ) { return $ fieldIndex ; } return $ this -> spec [ 'field' ] -> getIndexStart ( ) ; }
Get the current field index .
13,288
private function iterateSubSpec ( $ subSpecs , $ fieldIndex , $ subfieldIndex = null ) { $ valid = true ; foreach ( $ subSpecs as $ _subSpec ) { if ( is_array ( $ _subSpec ) ) { foreach ( $ _subSpec as $ this -> currentSubSpec ) { $ this -> setIndexStartEnd ( $ fieldIndex , $ subfieldIndex ) ; if ( $ valid = $ this -> checkSubSpec ( ) ) { break ; } } } else { $ this -> currentSubSpec = $ _subSpec ; $ this -> setIndexStartEnd ( $ fieldIndex , $ subfieldIndex ) ; if ( ! $ valid = $ this -> checkSubSpec ( ) ) { break ; } } } return $ valid ; }
Iterate on subspecs .
13,289
private function setIndexStartEnd ( $ fieldIndex , $ subfieldIndex = null ) { foreach ( [ 'leftSubTerm' , 'rightSubTerm' ] as $ side ) { if ( ! ( $ this -> currentSubSpec [ $ side ] instanceof CK \ MARCspec \ ComparisonStringInterface ) ) { if ( $ this -> spec [ 'field' ] [ 'tag' ] == $ this -> currentSubSpec [ $ side ] [ 'field' ] [ 'tag' ] ) { $ this -> currentSubSpec [ $ side ] [ 'field' ] -> setIndexStartEnd ( $ fieldIndex , $ fieldIndex ) ; if ( ! is_null ( $ subfieldIndex ) ) { if ( $ this -> currentSubSpec [ $ side ] -> offsetExists ( 'subfields' ) ) { foreach ( $ this -> currentSubSpec [ $ side ] [ 'subfields' ] as $ subfieldSpec ) { $ subfieldSpec -> setIndexStartEnd ( $ subfieldIndex , $ subfieldIndex ) ; } } } } } } }
Sets the start and end index of the current spec if it s an instance of CK \ MARCspec \ PositionOrRangeInterface .
13,290
private function checkSubSpec ( ) { $ validation = $ this -> cache -> validation ( $ this -> currentSubSpec ) ; if ( ! is_null ( $ validation ) ) { return $ validation ; } return $ this -> validateSubSpec ( ) ; }
Checks cache for subspec validation result . Validates SubSpec if it s not in cache .
13,291
private function validateSubSpec ( ) { if ( '!' != $ this -> currentSubSpec [ 'operator' ] && '?' != $ this -> currentSubSpec [ 'operator' ] ) { if ( false === ( $ this -> currentSubSpec [ 'leftSubTerm' ] instanceof CK \ MARCspec \ ComparisonStringInterface ) ) { $ leftSubTermReference = new self ( $ this -> currentSubSpec [ 'leftSubTerm' ] , $ this -> record , $ this -> cache ) ; if ( ! $ leftSubTerm = $ leftSubTermReference -> content ) { return $ this -> cache -> validation ( $ this -> currentSubSpec , false ) ; } } else { $ leftSubTerm [ ] = $ this -> currentSubSpec [ 'leftSubTerm' ] [ 'comparable' ] ; } } if ( false === ( $ this -> currentSubSpec [ 'rightSubTerm' ] instanceof CK \ MARCspec \ ComparisonStringInterface ) ) { $ rightSubTermReference = new self ( $ this -> currentSubSpec [ 'rightSubTerm' ] , $ this -> record , $ this -> cache ) ; $ rightSubTerm = $ rightSubTermReference -> content ; } else { $ rightSubTerm [ ] = $ this -> currentSubSpec [ 'rightSubTerm' ] [ 'comparable' ] ; } $ validation = false ; switch ( $ this -> currentSubSpec [ 'operator' ] ) { case '=' : if ( 0 < count ( array_intersect ( $ leftSubTerm , $ rightSubTerm ) ) ) { $ validation = true ; } break ; case '!=' : if ( 0 < count ( array_diff ( $ leftSubTerm , $ rightSubTerm ) ) ) { $ validation = true ; } break ; case '~' : if ( 0 < count ( array_uintersect ( $ leftSubTerm , $ rightSubTerm , function ( $ v1 , $ v2 ) { if ( strpos ( $ v1 , $ v2 ) !== false ) { return 0 ; } return - 1 ; } ) ) ) { $ validation = true ; } break ; case '!~' : if ( 0 < count ( array_uintersect ( $ leftSubTerm , $ rightSubTerm , function ( $ v1 , $ v2 ) { if ( strpos ( $ v1 , $ v2 ) === false ) { return 0 ; } return - 1 ; } ) ) ) { $ validation = true ; } break ; case '?' : if ( $ rightSubTerm ) { $ validation = true ; } break ; case '!' : if ( ! $ rightSubTerm ) { $ validation = true ; } break ; } $ this -> cache -> validation ( $ this -> currentSubSpec , $ validation ) ; return $ validation ; }
Validates a subSpec .
13,292
private function referenceFieldsByTag ( ) { $ tag = $ this -> spec [ 'field' ] [ 'tag' ] ; if ( $ this -> cache -> offsetExists ( $ tag ) ) { return $ this -> cache [ $ tag ] ; } if ( 'LDR' !== $ tag ) { $ _fieldRef = $ this -> record -> getFields ( $ tag , true ) ; } else { $ _fieldRef [ ] = $ this -> record -> getLeader ( ) ; } $ this -> cache [ $ tag ] = $ _fieldRef ; return $ _fieldRef ; }
Reference fields by field tag .
13,293
private function referenceFields ( ) { if ( $ this -> fields = $ this -> cache -> getData ( $ this -> spec [ 'field' ] ) ) { return $ this -> fields ; } if ( ! $ this -> fields = $ this -> referenceFieldsByTag ( ) ) { return ; } if ( $ _indexRange = $ this -> getIndexRange ( $ this -> spec [ 'field' ] , count ( $ this -> fields ) ) ) { $ prevTag = '' ; $ index = 0 ; foreach ( $ this -> fields as $ position => $ field ) { if ( false == ( $ field instanceof File_MARC_Field ) ) { continue ; } $ tag = $ field -> getTag ( ) ; $ index = ( $ prevTag == $ tag or '' == $ prevTag ) ? $ index : 0 ; if ( ! in_array ( $ index , $ _indexRange ) ) { unset ( $ this -> fields [ $ position ] ) ; } $ index ++ ; $ prevTag = $ tag ; } } if ( $ this -> spec -> offsetExists ( 'indicator' ) ) { foreach ( $ this -> fields as $ key => $ field ) { if ( ! $ field -> isDataField ( ) ) { unset ( $ this -> fields [ $ key ] ) ; } } } }
Reference fields . Filter by index and indicator .
13,294
private function referenceSubfields ( $ currentSubfieldSpec ) { $ baseSubfieldSpec = $ this -> baseSpec . $ currentSubfieldSpec -> getBaseSpec ( ) ; if ( $ subfields = $ this -> cache -> getData ( $ this -> currentSpec [ 'field' ] , $ currentSubfieldSpec ) ) { return $ subfields ; } $ _subfields = $ this -> field -> getSubfields ( $ currentSubfieldSpec [ 'tag' ] ) ; if ( ! $ _subfields ) { $ this -> cache [ $ baseSubfieldSpec ] = [ ] ; return [ ] ; } if ( $ _indexRange = $ this -> getIndexRange ( $ currentSubfieldSpec , count ( $ _subfields ) ) ) { foreach ( $ _subfields as $ sfkey => $ item ) { if ( ! in_array ( $ sfkey , $ _indexRange ) || $ item -> isEmpty ( ) ) { unset ( $ _subfields [ $ sfkey ] ) ; } } } if ( $ _subfields ) { $ sf_values = array_values ( $ _subfields ) ; $ this -> cache [ $ baseSubfieldSpec ] = $ sf_values ; return $ sf_values ; } $ this -> cache [ $ baseSubfieldSpec ] = [ ] ; return [ ] ; }
Reference subfield contents and filter by index .
13,295
private function getIndexRange ( $ spec , $ total ) { $ lastIndex = $ total - 1 ; $ indexStart = $ spec [ 'indexStart' ] ; $ indexEnd = $ spec [ 'indexEnd' ] ; if ( '#' === $ indexStart ) { if ( '#' === $ indexEnd or 0 === $ indexEnd ) { return [ $ lastIndex ] ; } $ indexStart = $ lastIndex ; $ indexEnd = $ lastIndex - $ indexEnd ; $ indexEnd = ( 0 > $ indexEnd ) ? 0 : $ indexEnd ; } else { if ( $ lastIndex < $ indexStart ) { return [ $ indexStart ] ; } $ indexEnd = ( '#' === $ indexEnd ) ? $ lastIndex : $ indexEnd ; if ( $ indexEnd > $ lastIndex ) { $ indexEnd = $ lastIndex ; } } return range ( $ indexStart , $ indexEnd ) ; }
Calculates a range from indexStart and indexEnd .
13,296
public function ref ( $ spec , $ value ) { array_push ( $ this -> data , $ value ) ; $ value = $ this -> cache -> getContents ( $ spec , [ $ value ] ) ; $ this -> content = array_merge ( $ this -> content , $ value ) ; }
Reference data and set content .
13,297
public function cannot ( $ permissionName , $ params = [ ] , $ allowCaching = TRUE ) { return ! $ this -> can ( $ permissionName , $ params , $ allowCaching ) ; }
Checks if the user cannot perform the operation as specified by the given permission .
13,298
public function can ( $ permissionName , $ params = [ ] , $ allowCaching = TRUE ) { if ( is_array ( $ permissionName ) ) { foreach ( array_unique ( $ permissionName ) as $ permissionNameItem ) { if ( parent :: can ( $ permissionNameItem , $ params , $ allowCaching ) ) { return TRUE ; } } return FALSE ; } return parent :: can ( $ permissionName , $ params , $ allowCaching ) ; }
Checks if the user can perform the operation as specified by the given permission .
13,299
public function load ( string $ configPath , $ overwrite = false ) : void { if ( ! file_exists ( $ configPath ) ) { return ; } $ config = include $ configPath ; if ( ! is_array ( $ config ) && ! is_object ( $ config ) ) { return ; } if ( is_object ( $ config ) ) { $ config = get_object_vars ( $ config ) ; } $ this -> loadArray ( $ config , $ overwrite ) ; }
Loads configuration from configuration file .