idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
9,300
public function delete ( $ key ) { $ filename = $ this -> getKeyCode ( $ key ) ; $ this -> memcacheObj -> delete ( $ filename ) ; }
Remove a key from cache
9,301
public function create ( $ alias , $ source , $ dependencies = [ ] , $ options = [ ] ) { $ assetType = isset ( $ options [ 'type' ] ) ? $ options [ 'type' ] : '' ; if ( isset ( $ this -> _customTypes [ $ assetType ] ) ) { $ assetType = $ this -> _customTypes [ $ assetType ] ; } elseif ( is_callable ( $ source ) ) { $ assetType = 'Callback' ; } elseif ( is_string ( $ source ) ) { $ ext = strtolower ( FS :: ext ( $ source ) ) ; if ( $ ext === 'js' ) { $ assetType = 'JsFile' ; } elseif ( $ ext === 'css' ) { $ assetType = 'CssFile' ; } elseif ( $ ext === 'less' ) { $ assetType = 'LessFile' ; } elseif ( $ ext === 'jsx' ) { $ assetType = 'JsxFile' ; } } elseif ( is_array ( $ source ) ) { $ assetType = 'Collection' ; } $ className = __NAMESPACE__ . '\\Asset\\' . $ assetType ; if ( class_exists ( $ className ) ) { $ options = is_array ( $ options ) ? new Data ( $ options ) : $ options ; return new $ className ( $ this -> getManager ( ) , $ alias , $ source , $ dependencies , $ options ) ; } throw new Exception ( 'Undefined asset type: ' . print_r ( $ source , true ) ) ; }
Create asset instance .
9,302
public function getStatusOfTaskWithId ( $ taskId ) { $ task = $ this -> taskRepo -> find ( $ taskId ) ; if ( ! ( $ task instanceof Task ) ) { return Task :: STATUS_GONE ; } return $ task -> getStatus ( ) ; }
Returns the current status of a task
9,303
public function cleanUpTasks ( $ timePeriod ) { $ query = $ this -> entityManager -> createQuery ( 'DELETE FROM WebdevviePheanstalkTaskQueueBundle:Task t WHERE t.status = :status and t.created <= :older' ) ; $ query -> setParameter ( 'status' , array ( Task :: STATUS_DONE ) ) ; $ query -> setParameter ( 'older' , date ( "Y-m-d H:i:s" , time ( ) - $ timePeriod ) ) ; $ query -> execute ( ) ; }
Cleans up tasks that are marked as done
9,304
public function reserveTask ( $ tube = null ) { if ( is_null ( $ tube ) ) { $ tube = $ this -> defaultTube ; } $ inTask = $ this -> beanstalk -> watch ( $ tube ) -> ignore ( 'default' ) -> reserve ( 2 ) ; if ( $ inTask === false ) { return null ; } $ data = $ inTask -> getData ( ) ; $ parts = explode ( "::" , $ data , 2 ) ; if ( count ( $ parts ) !== 2 ) { $ this -> beanstalk -> delete ( $ inTask ) ; throw new TaskQueueServiceException ( "Invalid format in TaskQueue {$tube}" ) ; } try { $ taskObject = $ this -> serializer -> deserialize ( $ parts [ 1 ] , $ parts [ 0 ] , 'json' ) ; } catch ( UnsupportedFormatException $ exception ) { $ this -> beanstalk -> delete ( $ inTask ) ; throw new TaskQueueServiceException ( "Invalid format in TaskQueue {$tube} " ) ; } catch ( \ ReflectionException $ exception ) { $ this -> beanstalk -> delete ( $ inTask ) ; throw new TaskQueueServiceException ( "Invalid format in TaskQueue {$tube} class " . $ parts [ 0 ] . ' is unknown' ) ; } if ( ! ( $ taskObject instanceof TaskDescriptionInterface ) ) { $ this -> beanstalk -> delete ( $ inTask ) ; throw new TaskQueueServiceException ( "Invalid data in TaskQueue {$tube}" ) ; } if ( ! $ this -> databaseDisabled ) { $ taskEntity = $ this -> taskRepo -> find ( $ taskObject -> getTaskIdentifier ( ) ) ; } else { $ taskEntity = new Task ( $ taskObject , '' , $ tube ) ; } if ( ! ( $ taskEntity instanceof Task ) ) { $ this -> beanstalk -> delete ( $ inTask ) ; throw new TaskQueueServiceException ( "Unable to find taskEntity for task:" . $ taskObject -> getTaskIdentifier ( ) ) ; } $ workPackage = new WorkPackage ( $ taskEntity , $ inTask , $ taskObject ) ; $ this -> updateTaskStatus ( $ workPackage , Task :: STATUS_WORKING ) ; return $ workPackage ; }
Returns a task to work on .
9,305
public function markDone ( WorkPackage $ task , $ log ) { if ( $ this -> logWorkerOutputOnSuccess ) { $ this -> updateTaskLog ( $ task , $ log ) ; } $ this -> updateTaskStatus ( $ task , Task :: STATUS_DONE ) ; $ this -> beanstalk -> delete ( $ task -> getPheanstalkJob ( ) ) ; }
Deletes a task from the queue
9,306
public function markFailed ( WorkPackage $ task , $ log ) { if ( $ this -> logWorkerOutputOnFailure ) { $ this -> updateTaskLog ( $ task , $ log ) ; } $ this -> updateTaskStatus ( $ task , Task :: STATUS_FAILED ) ; $ this -> beanstalk -> delete ( $ task -> getPheanstalkJob ( ) ) ; }
Marks a job as failed and deletes it from the beanstalk tube
9,307
private function updateTaskLog ( WorkPackage $ task , $ log ) { if ( $ this -> databaseDisabled ) { return ; } $ taskEntity = $ task -> getTaskEntity ( ) ; if ( $ taskEntity instanceof Task ) { $ taskEntity -> setLog ( $ log ) ; $ this -> entityManager -> flush ( $ taskEntity ) ; } else { throw new TaskQueueServiceException ( "Entity is not of type Task" ) ; } }
Writes the log to the Task entity
9,308
private function updateTaskStatus ( WorkPackage $ task , $ status ) { if ( $ this -> databaseDisabled ) { return ; } $ taskEntity = $ task -> getTaskEntity ( ) ; if ( $ taskEntity instanceof Task ) { $ taskEntity -> setStatus ( $ status ) ; $ this -> entityManager -> flush ( $ taskEntity ) ; } else { throw new TaskQueueServiceException ( "Entity is not of type Task" ) ; } }
Updates the task status
9,309
public function readData ( $ pathFilename ) { $ pathFilename = ucfirst ( $ pathFilename ) ; $ pathFilename = realpath ( __DIR__ ) . "/../Template/{$pathFilename}.template" ; $ file = fopen ( $ pathFilename , 'r' ) ; if ( $ data = fread ( $ file , filesize ( $ pathFilename ) ) ) { return str_replace ( '<\?php' , '<?php' , $ data ) ; } else { throw new \ ErrorException ( realpath ( __DIR__ ) . "/../Template/{$pathFilename}.template not Found" ) ; } }
Read data form template folder
9,310
public function variables ( ) { if ( ! $ this -> hasKeyword ( 'STUB' ) ) { return $ this -> keyword ( 'HEADING' ) -> values ; } elseif ( ! $ this -> hasKeyword ( 'HEADING' ) ) { return $ this -> keyword ( 'STUB' ) -> values ; } else { return array_merge ( $ this -> keyword ( 'STUB' ) -> values , $ this -> keyword ( 'HEADING' ) -> values ) ; } }
Returns a list of all variables .
9,311
public function values ( $ variable ) { foreach ( $ this -> keywordList ( 'VALUES' ) as $ keyword ) { if ( $ keyword -> subKeys [ 0 ] == $ variable ) { return $ keyword -> values ; } } throw new RuntimeException ( sprintf ( 'Could not determine values of "%s".' , $ variable ) ) ; }
Returns a list of all possible values of a variable .
9,312
public function codes ( $ variable ) { foreach ( $ this -> keywordList ( 'CODES' ) as $ keyword ) { if ( $ keyword -> subKeys [ 0 ] == $ variable ) { return $ keyword -> values ; } } return null ; }
Returns a list of all possible codes of a variable .
9,313
public function index ( $ indices ) { $ this -> assertIndexMultipliers ( ) ; $ index = 0 ; for ( $ i = 0 , $ length = count ( $ this -> indexMultipliers ) ; $ i < $ length ; ++ $ i ) { $ index += $ indices [ $ i ] * $ this -> indexMultipliers [ $ i ] ; } return $ index ; }
Computes the index within the data matrix .
9,314
public function datum ( $ indices ) { $ this -> assertData ( ) ; $ index = $ this -> index ( $ indices ) ; if ( isset ( $ this -> data [ $ index ] ) ) { return $ this -> data [ $ index ] ; } else { return null ; } }
Gets a single data point .
9,315
public function keywordList ( $ keyword ) { $ this -> assertKeywords ( ) ; if ( isset ( $ this -> keywords [ $ keyword ] ) ) { return $ this -> keywords [ $ keyword ] ; } else { return [ ] ; } }
Returns all keywords with a given name .
9,316
public function keyword ( $ keyword ) { $ list = $ this -> keywordList ( $ keyword ) ; if ( empty ( $ list ) ) { throw new RuntimeException ( sprintf ( 'Keyword "%s" does not exist.' , $ keyword ) ) ; } return $ list [ 0 ] ; }
Returns the first keyword with a given name .
9,317
public function getFiles ( ) { $ iterator = new RecursiveDirectoryIterator ( $ this -> directory , FilesystemIterator :: SKIP_DOTS ) ; $ iterator = new RecursiveIteratorIterator ( $ iterator ) ; $ iterator -> rewind ( ) ; return $ iterator ; }
Give back a list of all files in a given directory recursively This returns the filename relative to the given directory .
9,318
public function render ( ) { $ responseData = array ( "status" => $ this -> _statusCode , "body" => $ this -> _content , "errors" => $ this -> _errors ) ; return json_encode ( $ responseData ) ; }
Ajax render function
9,319
public function findFile ( $ class ) { if ( xcache_isset ( $ this -> prefix . $ class ) ) { $ file = xcache_get ( $ this -> prefix . $ class ) ; } else { xcache_set ( $ this -> prefix . $ class , $ file = $ this -> classFinder -> findFile ( $ class ) ) ; } return $ file ; }
Finds a file by class name while caching lookups to Xcache .
9,320
public function addHttpHeader ( $ http_header , $ value ) { $ field = EnumRequestOption :: HTTP_HEADERS ; $ http_headers = isset ( $ this -> options [ $ field ] ) ? $ this -> options [ $ field ] : [ ] ; foreach ( $ http_headers as $ key => $ header ) { if ( strpos ( $ header , $ http_header ) === 0 ) { $ http_headers [ $ key ] = "$http_header: $value\r\n" ; return ; } } $ http_headers [ $ http_header ] = $ value ; $ this -> options [ $ field ] = $ http_headers ; }
Add HTTP Header
9,321
public function getHttpHeaders ( ) { $ field = EnumRequestOption :: HTTP_HEADERS ; $ http_deaders = isset ( $ this -> options [ $ field ] ) ? $ this -> options [ $ field ] : [ ] ; $ http_deaders = array_merge ( $ this -> getDefaultHttpHeaders ( ) , $ http_deaders ) ; return $ http_deaders ; }
Get HTTP headers
9,322
public function getExtraOptions ( ) { $ field = EnumRequestOption :: EXTRA_OPTIONS ; return isset ( $ this -> options [ $ field ] ) ? $ this -> options [ $ field ] : [ ] ; }
Get extra options
9,323
public function getVerbose ( ) { $ field = EnumRequestOption :: VERBOSE ; return isset ( $ this -> options [ $ field ] ) ? $ this -> options [ $ field ] : false ; }
Get verbose options
9,324
public function transform ( $ content ) { $ content = $ this -> entityToArray ( Content :: class , $ content ) ; return [ 'id' => $ this -> setNullableValue ( $ content [ 'id' ] ) , 'parentId' => $ this -> setNullableValue ( $ content [ 'parent_id' ] ) , 'type' => $ content [ 'type' ] , 'theme' => $ content [ 'theme' ] , 'weight' => ( int ) $ content [ 'weight' ] , 'rating' => ( int ) $ content [ 'rating' ] , 'visits' => ( int ) $ content [ 'visits' ] , 'isActive' => ( bool ) $ content [ 'is_active' ] , 'isOnHome' => ( bool ) $ content [ 'is_on_home' ] , 'isCommentAllowed' => ( bool ) $ content [ 'is_comment_allowed' ] , 'isPromoted' => ( bool ) $ content [ 'is_promoted' ] , 'isSticky' => ( bool ) $ content [ 'is_sticky' ] , 'path' => $ this -> buildPath ( $ content [ 'path' ] ) , 'publishedAt' => $ content [ 'published_at' ] , 'createdAt' => $ content [ 'created_at' ] , 'updatedAt' => $ content [ 'updated_at' ] ] ; }
Transforms content entity
9,325
public function transform ( $ file ) { $ thumb = null ; if ( $ file -> type === 'image' ) { $ width = config ( 'gzero.image.thumb.width' ) ; $ height = config ( 'gzero.image.thumb.height' ) ; $ thumb = croppaUrl ( $ file -> getFullPath ( ) , $ width , $ height ) ; } $ file = $ this -> entityToArray ( File :: class , $ file ) ; return [ 'id' => ( int ) $ file [ 'id' ] , 'type' => $ file [ 'type' ] , 'name' => $ file [ 'name' ] , 'extension' => $ file [ 'extension' ] , 'size' => ( int ) $ file [ 'size' ] , 'mimeType' => $ file [ 'mime_type' ] , 'info' => $ file [ 'info' ] , 'thumb' => $ thumb , 'weight' => $ this -> setPivotNullableValue ( $ file , 'weight' ) , 'isActive' => ( bool ) $ file [ 'is_active' ] , 'createdBy' => ( int ) $ file [ 'created_by' ] , 'createdAt' => $ file [ 'created_at' ] , 'updatedAt' => $ file [ 'updated_at' ] ] ; }
Transforms file entity
9,326
private function setPivotNullableValue ( $ file , $ key ) { if ( array_key_exists ( 'pivot' , $ file ) ) { return $ this -> setNullableValue ( $ file [ 'pivot' ] [ $ key ] ) ; } return null ; }
Returns pivot integer value or null
9,327
public function execute ( UrlChain $ urlChain , RendererInterface $ renderer , OutputInterface $ output ) { $ result = 0 ; foreach ( $ urlChain -> getUrls ( ) as $ url ) { $ result = $ result | $ this -> executeUrl ( $ this -> client , $ url , $ renderer , $ output ) ; } return $ result ; }
Renders the output of the result of executing some urls given a client instance
9,328
protected function executeUrl ( ClientInterface $ client , Url $ url , RendererInterface $ renderer , OutputInterface $ output ) { $ resultHTTPCode = $ client -> getResponseHTTPCode ( $ url ) ; $ resultExecution = in_array ( $ resultHTTPCode , $ url -> getAcceptableHttpCodes ( ) ) ? 0 : 1 ; $ renderer -> render ( $ output , $ url , $ resultHTTPCode , ( 0 === $ resultExecution ) ) ; return $ resultExecution ; }
Executes an URL and render the result given a renderer .
9,329
public function createStream ( $ serverconfig = null ) { if ( $ serverconfig == null ) { $ serverconfig = $ this -> default_streamserver_config ; } $ stream = new $ this -> stream_class ; $ stream -> setRtmpServer ( $ this -> streamserver_config [ $ serverconfig ] [ 'rtmp_url' ] ) ; $ stream -> setRtmpApp ( $ this -> streamserver_config [ $ serverconfig ] [ 'app' ] ) ; return $ stream ; }
returns a new stream object preset with default streamserver config
9,330
public function startRecording ( $ stream ) { $ parts = explode ( '/' , $ this -> streamserver_config [ $ stream -> getRtmpServer ( ) ] [ 'rtmp_url' ] ) ; $ rtmp_app = end ( $ parts ) ; $ success = $ this -> record ( $ this -> streamserver_config [ $ stream -> getRtmpServer ( ) ] [ 'rtmp_control' ] , $ rtmp_app , $ stream -> getUniqID ( ) ) ; if ( $ success ) { $ stream -> setTechnicalStatus ( Stream :: STATE_RECORDING ) ; $ this -> em -> persist ( $ stream ) ; $ this -> em -> flush ( ) ; $ event = new StartRecordingStreamEvent ( $ stream ) ; $ this -> dispatcher -> dispatch ( OktolabMediaEvent :: STREAM_START_RECORDING , $ event ) ; return true ; } return false ; }
start recording a stream .
9,331
public function endRecording ( $ stream ) { $ parts = explode ( '/' , $ this -> streamserver_config [ $ stream -> getRtmpServer ( ) ] [ 'rtmp_url' ] ) ; $ rtmp_app = end ( $ parts ) ; $ success = $ this -> record ( $ this -> streamserver_config [ $ stream -> getRtmpServer ( ) ] [ 'rtmp_control' ] , $ rtmp_app , $ stream -> getUniqID ( ) , false ) ; if ( $ success ) { $ stream -> setTechnicalStatus ( Stream :: STATE_ENDED ) ; $ this -> em -> persist ( $ stream ) ; $ this -> em -> flush ( ) ; return true ; } return false ; }
end recording a stream
9,332
public function addPublishToAdress ( $ stream , $ rtmp_adress , $ clientid , $ new_name , $ type = 'publisher' , $ srv = null ) { return $ this -> redirect ( $ stream -> getRtmpApp ( ) , $ stream -> getUniqID ( ) , $ rtmp_adress , $ clientid , $ new_name , $ type , $ srv ) ; }
adds a push to another rtmp server . can be used to send a stream to facebook youtube etc .
9,333
public function drop ( $ control_url , $ app , $ name , $ type = 'publisher' , $ addr = null , $ clientid = null , $ srv = null ) { $ query = [ ] ; $ query [ 'app' ] = $ app ; $ query [ 'name' ] = $ name ; if ( $ addr ) { $ query [ 'addr' ] = $ addr ; } if ( $ clientid ) { $ query [ 'clientid' ] = $ clientid ; } if ( $ srv ) { $ query [ 'srv' ] = $ srv ; } $ client = new Client ( ) ; try { $ response = $ client -> request ( 'GET' , $ url . '/control/drop/' . $ type , [ 'query' => $ query ] ) ; } catch ( RequestException $ e ) { return false ; } catch ( Exception $ e ) { return false ; } return true ; }
send a drop command to the rtmp server
9,334
public function redirect ( $ control_url , $ app , $ name , $ new_adress , $ new_clientid , $ new_name , $ type = 'publisher' , $ srv = null ) { $ query = [ ] ; $ query [ 'app' ] = $ app ; $ query [ 'name' ] = $ name ; $ query [ 'addr' ] = $ new_adress ; $ query [ 'clientid' ] = $ new_clientid ; $ query [ 'newname' ] = $ new_name ; if ( $ srv ) { $ query [ 'srv' ] = $ srv ; } $ client = new Client ( ) ; try { $ response = $ client -> request ( 'GET' , $ url . '/control/redirect/' . $ type , [ 'query' => $ query ] ) ; } catch ( RequestException $ e ) { return false ; } catch ( Exception $ e ) { return false ; } return true ; }
sends a redirect command to the rtmp server
9,335
public function getFile ( $ name ) { if ( ! isset ( $ this -> files ) ) { $ files = $ this -> getUploadedFiles ( ) ; foreach ( $ files as $ file ) { $ key = $ file -> getKey ( ) ; if ( isset ( $ key ) ) { $ this -> files [ $ key ] = $ file ; } else { $ this -> files [ ] = $ file ; } } } if ( isset ( $ this -> files [ $ name ] ) ) { return $ this -> files [ $ name ] ; } else { throw new \ InvalidArgumentException ( "Upload file '$name' is empty" ) ; } }
Gets upload file object by name
9,336
public function getBody ( ) { if ( ! isset ( $ this -> body ) ) { if ( function_exists ( 'http_get_request_body' ) ) { $ this -> body = http_get_request_body ( ) ; } else { $ this -> body = @ file_get_contents ( 'php://input' ) ; } } return $ this -> body ; }
Gets post body content
9,337
public static function get ( $ template ) { if ( self :: $ twig === null ) self :: initialize ( ) ; return self :: $ twig -> loadTemplate ( $ template . '.twig' ) ; }
Retreive a twig template object
9,338
public static function display ( $ template , $ target_id ) { if ( self :: $ twig === null ) self :: initialize ( ) ; self :: $ render_actions [ ] = array ( "type" => "display_tpl" , "template" => $ template , "target_id" => $ target_id ) ; }
Append a template render action to the render queue
9,339
public static function render ( ) { $ apiMode = Request :: isAPI ( ) ; if ( self :: $ twig === null ) self :: initialize ( ) ; $ data = Request :: getAllData ( ) ; if ( ! $ apiMode ) { $ data [ "siteName" ] = Configuration :: get ( "dachi.siteName" , "Unnamed Dachi Installation" ) ; $ data [ "timezone" ] = Configuration :: get ( "dachi.timezone" , "Europe/London" ) ; $ data [ "domain" ] = Configuration :: get ( "dachi.domain" , "localhost" ) ; $ data [ "baseURL" ] = Configuration :: get ( "dachi.baseURL" , "/" ) ; $ data [ "assetsURL" ] = str_replace ( "%v" , Kernel :: getGitHash ( ) , Configuration :: get ( "dachi.assetsURL" , "/build/" ) ) ; $ data [ "renderTPL" ] = self :: getRenderTemplate ( ) ; $ data [ "URI" ] = Request :: getFullUri ( ) ; } if ( $ apiMode ) { $ response = array ( "data" => $ data , "response" => Request :: getResponseCode ( ) ) ; return json_echo ( $ response ) ; } else if ( Request :: isAjax ( ) ) { $ response = array ( "render_tpl" => self :: getRenderTemplate ( ) , "data" => $ data , "response" => Request :: getResponseCode ( ) , "render_actions" => self :: $ render_actions ) ; return json_echo ( $ response ) ; } else { $ data [ "response" ] = Request :: getResponseCode ( ) ; $ response = self :: $ twig -> render ( self :: getRenderTemplate ( true ) , $ data ) ; foreach ( array_reverse ( self :: $ render_actions ) as $ action ) { switch ( $ action [ "type" ] ) { case "redirect" : if ( $ action [ "soft" ] !== true ) header ( "Location: " . $ action [ "location" ] ) ; break ; case "display_tpl" : $ match = preg_match ( "/<dachi-ui-block id=[\"']" . preg_quote ( $ action [ "target_id" ] ) . "[\"'][^>]*>([\s\S]*)<\/dachi-ui-block>/U" , $ response , $ matches ) ; if ( $ match ) { $ replacement = "<dachi-ui-block id='" . $ action [ "target_id" ] . "'>" . self :: $ twig -> render ( $ action [ "template" ] . '.twig' , $ data ) . "</dachi-ui-block>" ; $ response = str_replace ( $ matches [ 0 ] , $ replacement , $ response ) ; } break ; } } echo $ response ; } }
Render the render queue to the browser
9,340
public static function redirect ( $ location , $ soft = false ) { if ( substr ( $ location , 0 , 4 ) !== "http" ) $ location = Configuration :: get ( "dachi.baseURL" ) . $ location ; self :: $ render_actions [ ] = array ( "type" => "redirect" , "location" => $ location , "soft" => $ soft ) ; }
Append a redirect action to the render queue .
9,341
public function access ( $ user ) { $ user = User :: findOrFail ( $ user -> id ) ; return $ user -> hasPermission ( 'laralum::users.access' ) || $ user -> superAdmin ( ) ; }
Determine if the current user can view users module .
9,342
public function view ( $ user ) { $ user = User :: findOrFail ( $ user -> id ) ; return $ user -> hasPermission ( 'laralum::users.view' ) || $ user -> superAdmin ( ) ; }
Determine if the current user can view users .
9,343
public function create ( $ user ) { $ user = User :: findOrFail ( $ user -> id ) ; return $ user -> hasPermission ( 'laralum::users.create' ) || $ user -> superAdmin ( ) ; }
Determine if the current user can create users .
9,344
public function update ( $ user , User $ userToManage ) { if ( $ userToManage -> id == $ user -> id || $ userToManage -> superAdmin ( ) ) { return false ; } $ user = User :: findOrFail ( $ user -> id ) ; return $ user -> hasPermission ( 'laralum::users.update' ) || $ user -> superAdmin ( ) ; }
Determine if the current user can update users .
9,345
public function isQueryAllowed ( ezcDbHandler $ db , $ query ) { if ( strstr ( $ query , 'AUTO_INCREMENT' ) ) { return false ; } if ( substr ( $ query , 0 , 10 ) == 'DROP TABLE' ) { $ tableName = substr ( $ query , strlen ( 'DROP TABLE "' ) , - 1 ) ; $ result = $ db -> query ( "SELECT count( table_name ) AS count FROM user_tables WHERE table_name='$tableName'" ) -> fetchAll ( ) ; if ( $ result [ 0 ] [ 'count' ] == 1 ) { $ sequences = $ db -> query ( "SELECT sequence_name FROM user_sequences" ) -> fetchAll ( ) ; array_walk ( $ sequences , create_function ( '&$item,$key' , '$item = $item[0];' ) ) ; foreach ( $ sequences as $ sequenceName ) { if ( substr ( $ sequenceName , 0 , strlen ( $ tableName ) ) == $ tableName ) { $ db -> query ( "DROP SEQUENCE \"{$sequenceName}\"" ) ; } } return true ; } else { return false ; } } return true ; }
Checks if query allowed .
9,346
protected function generateAdditionalDropSequenceStatements ( ezcDbSchemaDiff $ dbSchemaDiff , ezcDbHandler $ db ) { $ reader = new ezcDbSchemaOracleReader ( ) ; $ schema = $ reader -> loadFromDb ( $ db ) -> getSchema ( ) ; foreach ( $ dbSchemaDiff -> removedTables as $ table => $ true ) { foreach ( $ schema [ $ table ] -> fields as $ name => $ field ) { if ( $ field -> autoIncrement !== true ) { continue ; } $ seqName = ezcDbSchemaOracleHelper :: generateSuffixCompositeIdentName ( $ table , $ name , "seq" ) ; if ( strpos ( $ seqName , $ table ) !== 0 ) { $ this -> queries [ ] = "DROP SEQUENCE \"$seqName\"" ; } } } }
Generate additional drop sequence statements
9,347
public function build ( ) { $ annotationReader = $ this -> annotationReader ; if ( null === $ annotationReader ) { $ annotationReader = new AnnotationReader ( ) ; if ( null !== $ this -> cacheDirectory ) { $ cacheDirectory = sprintf ( '%s/annotations' , $ this -> cacheDirectory ) ; $ this -> createDirectory ( $ cacheDirectory ) ; $ annotationReader = new CachedReader ( $ annotationReader , new FilesystemCache ( $ cacheDirectory ) ) ; } } $ metadataDriver = $ this -> driverFactory -> createDriver ( $ this -> metadataDirectories , $ annotationReader ) ; $ metadataFactory = new MetadataFactory ( $ metadataDriver , null , $ this -> debug ) ; $ metadataFactory -> setIncludeInterfaces ( $ this -> includeInterfaceMetadata ) ; if ( null !== $ this -> cacheDirectory ) { $ directory = sprintf ( '%s/metadata' , $ this -> cacheDirectory ) ; $ this -> createDirectory ( $ directory ) ; $ metadataFactory -> setCache ( new FileCache ( $ directory ) ) ; } return new OpenGraphGenerator ( $ metadataFactory ) ; }
Create open graph object
9,348
public function setCacheDirectory ( $ directory ) { if ( ! is_dir ( $ directory ) ) { $ this -> createDirectory ( $ directory ) ; } if ( ! is_writable ( $ directory ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The cache directory "%s" is not writable.' , $ dir ) ) ; } $ this -> cacheDirectory = $ directory ; return $ this ; }
Set cache directory
9,349
public function useSession ( ) { $ this -> session = $ this -> getRequest ( ) -> getAttribute ( 'session' ) ; if ( ! isset ( $ this -> session ) ) { $ this -> session = & $ _SESSION ; } }
Link the session to the session property in the controller
9,350
public static function factoryReference ( $ reference ) { $ className = $ reference [ 2 ] ; if ( ! class_exists ( $ className ) ) { throw new Exceptions \ EntityClassNotFoundException ( "factoryReference called for a class that can't be found, $className." ) ; } $ entity = call_user_func ( [ $ className , 'factory' ] ) ; $ entity -> referenceSleep ( $ reference ) ; return $ entity ; }
Create a new sleeping reference instance .
9,351
public function & __get ( $ name ) { if ( $ name === 'guid' ) { return $ this -> $ name ; } if ( $ this -> isASleepingReference ) { $ this -> referenceWake ( ) ; } if ( $ name === 'cdate' || $ name === 'mdate' || $ name === 'tags' ) { return $ this -> $ name ; } if ( isset ( $ this -> sdata [ $ name ] ) ) { $ this -> data [ $ name ] = unserialize ( $ this -> sdata [ $ name ] ) ; unset ( $ this -> sdata [ $ name ] ) ; } if ( isset ( $ this -> entityCache [ $ name ] ) ) { if ( $ this -> data [ $ name ] [ 0 ] === 'nymph_entity_reference' ) { if ( $ this -> entityCache [ $ name ] === 0 ) { $ className = $ this -> data [ $ name ] [ 2 ] ; if ( ! class_exists ( $ className ) ) { throw new Exceptions \ EntityCorruptedException ( "Entity reference refers to a class that can't be found, " . "$className." ) ; } $ this -> entityCache [ $ name ] = $ className :: factoryReference ( $ this -> data [ $ name ] ) ; $ this -> entityCache [ $ name ] -> useSkipAc ( $ this -> useSkipAc ) ; } return $ this -> entityCache [ $ name ] ; } else { throw new Exceptions \ EntityCorruptedException ( "Entity data has become corrupt and cannot be determined." ) ; } } if ( ! isset ( $ this -> data [ $ name ] ) ) { return $ this -> NULL_CONST ; } try { if ( is_array ( $ this -> data [ $ name ] ) ) { array_walk ( $ this -> data [ $ name ] , [ $ this , 'referenceToEntity' ] ) ; } elseif ( is_object ( $ this -> data [ $ name ] ) && ! ( ( is_a ( $ this -> data [ $ name ] , '\Nymph\Entity' ) || is_a ( $ this -> data [ $ name ] , '\SciActive\HookOverride' ) ) && is_callable ( [ $ this -> data [ $ name ] , 'toReference' ] ) ) ) { foreach ( $ this -> data [ $ name ] as & $ curProperty ) { $ this -> referenceToEntity ( $ curProperty , null ) ; } unset ( $ curProperty ) ; } } catch ( Exceptions \ EntityClassNotFoundException $ e ) { throw new Exceptions \ EntityCorruptedException ( $ e -> getMessage ( ) ) ; } return $ this -> data [ $ name ] ; }
Retrieve a variable .
9,352
public function __isset ( $ name ) { if ( $ this -> isASleepingReference ) { $ this -> referenceWake ( ) ; } if ( $ name === 'guid' || $ name === 'cdate' || $ name === 'mdate' || $ name === 'tags' ) { return isset ( $ this -> $ name ) ; } if ( isset ( $ this -> sdata [ $ name ] ) ) { $ this -> data [ $ name ] = unserialize ( $ this -> sdata [ $ name ] ) ; unset ( $ this -> sdata [ $ name ] ) ; } return isset ( $ this -> data [ $ name ] ) ; }
Checks whether a variable is set .
9,353
private function entityToReference ( & $ item , $ key ) { if ( $ this -> isASleepingReference ) { $ this -> referenceWake ( ) ; } if ( ( is_a ( $ item , '\Nymph\Entity' ) || is_a ( $ item , '\SciActive\HookOverride' ) ) && isset ( $ item -> guid ) && is_callable ( [ $ item , 'toReference' ] ) ) { if ( ! isset ( $ this -> entityCache [ "referenceGuid__{$item->guid}" ] ) ) { $ this -> entityCache [ "referenceGuid__{$item->guid}" ] = clone $ item ; } $ item = $ item -> toReference ( ) ; } }
Check if an item is an entity and if it is convert it to a reference .
9,354
private function getDataReference ( $ item ) { if ( $ this -> isASleepingReference ) { $ this -> referenceWake ( ) ; } if ( ( is_a ( $ item , '\Nymph\Entity' ) || is_a ( $ item , '\SciActive\HookOverride' ) ) && is_callable ( [ $ item , 'toReference' ] ) ) { return $ item -> toReference ( ) ; } elseif ( is_array ( $ item ) ) { return array_map ( [ $ this , 'getDataReference' ] , $ item ) ; } elseif ( is_object ( $ item ) ) { foreach ( $ item as & $ curProperty ) { $ curProperty = $ this -> getDataReference ( $ curProperty ) ; } unset ( $ curProperty ) ; } return $ item ; }
Convert entities to references and return the result .
9,355
public function referenceSleep ( $ reference ) { if ( count ( $ reference ) !== 3 || $ reference [ 0 ] !== 'nymph_entity_reference' || ! is_int ( $ reference [ 1 ] ) || ! is_string ( $ reference [ 2 ] ) ) { throw new Exceptions \ InvalidParametersException ( 'referenceSleep expects parameter 1 to be a valid Nymph entity ' . 'reference.' ) ; } $ thisClass = get_class ( $ this ) ; if ( $ reference [ 2 ] !== $ thisClass ) { throw new Exceptions \ InvalidParametersException ( "referenceSleep can only be called with an entity reference of the " . "same class. Given class: {$reference[2]}; this class: $thisClass." ) ; } $ this -> isASleepingReference = true ; $ this -> guid = $ reference [ 1 ] ; $ this -> sleepingReference = $ reference ; }
Set up a sleeping reference .
9,356
private function referenceWake ( ) { if ( ! $ this -> isASleepingReference ) { return true ; } if ( ! class_exists ( $ this -> sleepingReference [ 2 ] ) ) { throw new Exceptions \ EntityClassNotFoundException ( "Tried to wake sleeping reference entity that refers to a class " . "that can't be found, {$this->sleepingReference[2]}." ) ; } $ entity = Nymph :: getEntity ( [ 'class' => $ this -> sleepingReference [ 2 ] , 'skip_ac' => $ this -> useSkipAc ] , [ '&' , 'guid' => $ this -> sleepingReference [ 1 ] ] ) ; if ( ! isset ( $ entity ) ) { return false ; } $ this -> isASleepingReference = false ; $ this -> sleepingReference = null ; $ this -> guid = $ entity -> guid ; $ this -> tags = $ entity -> tags ; $ this -> cdate = $ entity -> cdate ; $ this -> mdate = $ entity -> mdate ; $ this -> putData ( $ entity -> getData ( ) , $ entity -> getSData ( ) ) ; return true ; }
Wake from a sleeping reference .
9,357
private function appendStreamFilters ( $ line ) { switch ( strtolower ( $ this -> headers [ 'Content-Transfer-Encoding' ] ) ) { case 'base64' : stream_filter_append ( $ this -> fp , 'convert.base64-decode' ) ; break ; case 'quoted-printable' : preg_match ( "/(\r\n|\r|\n)$/" , $ line , $ matches ) ; $ lb = count ( $ matches ) > 0 ? $ matches [ 0 ] : ezcMailTools :: lineBreak ( ) ; $ param = array ( 'line-break-chars' => $ lb ) ; stream_filter_append ( $ this -> fp , 'convert.quoted-printable-decode' , STREAM_FILTER_WRITE , $ param ) ; break ; case '7bit' : case '8bit' : break ; default : break ; } }
Sets the correct stream filters for the attachment .
9,358
public function parseBody ( $ line ) { if ( $ line !== '' ) { if ( $ this -> dataWritten === false ) { $ this -> appendStreamFilters ( $ line ) ; $ this -> dataWritten = true ; } fwrite ( $ this -> fp , $ line ) ; } }
Parse the body of a message line by line .
9,359
public function finish ( ) { fclose ( $ this -> fp ) ; $ this -> fp = null ; if ( $ this -> mainType == "application" && ( $ this -> subType == 'pgp-signature' || $ this -> subType == 'pgp-keys' || $ this -> subType == 'pgp-encrypted' ) ) { return null ; } $ filePart = new self :: $ fileClass ( $ this -> fileName ) ; $ filePart -> setHeaders ( $ this -> headers -> getCaseSensitiveArray ( ) ) ; ezcMailPartParser :: parsePartHeaders ( $ this -> headers , $ filePart ) ; switch ( strtolower ( $ this -> mainType ) ) { case 'image' : $ filePart -> contentType = ezcMailFile :: CONTENT_TYPE_IMAGE ; break ; case 'audio' : $ filePart -> contentType = ezcMailFile :: CONTENT_TYPE_AUDIO ; break ; case 'video' : $ filePart -> contentType = ezcMailFile :: CONTENT_TYPE_VIDEO ; break ; case 'application' : $ filePart -> contentType = ezcMailFile :: CONTENT_TYPE_APPLICATION ; break ; } $ filePart -> mimeType = $ this -> subType ; $ matches = array ( ) ; if ( preg_match ( '/^\s*inline;?/i' , $ this -> headers [ 'Content-Disposition' ] , $ matches ) ) { $ filePart -> dispositionType = ezcMailFile :: DISPLAY_INLINE ; } if ( preg_match ( '/^\s*attachment;?/i' , $ this -> headers [ 'Content-Disposition' ] , $ matches ) ) { $ filePart -> dispositionType = ezcMailFile :: DISPLAY_ATTACHMENT ; } $ filePart -> size = filesize ( $ this -> fileName ) ; return $ filePart ; }
Return the result of the parsed file part .
9,360
public function map ( $ method , $ route , $ handler ) { $ this [ 'router' ] -> map ( $ method , $ route , $ handler ) ; return $ this ; }
Adds a handler to the routing table for a given route .
9,361
public function handleRequest ( Request $ req ) { $ config = $ this [ 'config' ] ; if ( ! $ config -> get ( 'app.hostname' ) ) { $ config -> set ( 'app.hostname' , $ req -> host ( ) ) ; } $ res = new Response ( ) ; try { $ routeInfo = $ this [ 'router' ] -> dispatch ( $ req -> method ( ) , $ req -> path ( ) ) ; $ this [ 'routeInfo' ] = $ routeInfo ; if ( isset ( $ routeInfo [ 2 ] ) ) { $ req -> setParams ( $ routeInfo [ 2 ] ) ; } $ dispatch = new DispatchMiddleware ( ) ; $ dispatch -> setApp ( $ this ) ; $ this -> middleware ( $ dispatch ) ; return $ this -> runMiddleware ( $ req , $ res ) ; } catch ( \ Exception $ e ) { return $ this [ 'exception_handler' ] ( $ req , $ res , $ e ) ; } catch ( \ Error $ e ) { return $ this [ 'php_error_handler' ] ( $ req , $ res , $ e ) ; } }
Builds a response to an incoming request by routing it through the application .
9,362
public function runMiddleware ( Request $ req , Response $ res ) { $ this -> initMiddleware ( ) -> rewind ( ) ; return $ this -> nextMiddleware ( $ req , $ res ) ; }
Runs the middleware chain .
9,363
public function nextMiddleware ( Request $ req , Response $ res ) { $ middleware = $ this -> middleware -> current ( ) ; if ( ! $ middleware ) { return $ res ; } $ this -> middleware -> next ( ) ; return $ middleware ( $ req , $ res , [ $ this , 'nextMiddleware' ] ) ; }
Calls the next middleware in the chain . DO NOT call directly .
9,364
public static function filter ( $ value , bool $ allowNull = false ) { if ( self :: valueIsNullAndValid ( $ allowNull , $ value ) ) { return null ; } if ( $ value instanceof \ DateTimeZone ) { return $ value ; } if ( ! is_string ( $ value ) || trim ( $ value ) == '' ) { throw new FilterException ( '$value not a non-empty string' ) ; } try { return new \ DateTimeZone ( $ value ) ; } catch ( \ Exception $ e ) { throw new FilterException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } }
Filters the given value into a \ DateTimeZone object .
9,365
public static function logEntry ( $ entry ) { $ parts = explode ( "|" , $ entry , 5 ) ; $ array = array ( ) ; if ( count ( $ parts ) != 5 ) { $ array [ "timestamp" ] = 0 ; $ array [ "level" ] = TeamSpeak3 :: LOGLEVEL_ERROR ; $ array [ "channel" ] = "ParamParser" ; $ array [ "server_id" ] = "" ; $ array [ "msg" ] = Str :: factory ( "convert error (" . trim ( $ entry ) . ")" ) ; $ array [ "msg_plain" ] = $ entry ; $ array [ "malformed" ] = TRUE ; } else { $ array [ "timestamp" ] = strtotime ( trim ( $ parts [ 0 ] ) ) ; $ array [ "level" ] = self :: logLevel ( trim ( $ parts [ 1 ] ) ) ; $ array [ "channel" ] = trim ( $ parts [ 2 ] ) ; $ array [ "server_id" ] = trim ( $ parts [ 3 ] ) ; $ array [ "msg" ] = Str :: factory ( trim ( $ parts [ 4 ] ) ) ; $ array [ "msg_plain" ] = $ entry ; $ array [ "malformed" ] = FALSE ; } return $ array ; }
Converts a specified log entry string into an array containing the data .
9,366
public static function startWithNode ( string $ variable = null , array $ labels = [ ] ) : self { $ path = new self ; $ path -> elements = $ path -> elements -> add ( new Node ( $ variable , $ labels ) ) ; $ path -> lastOperation = Node :: class ; return $ path ; }
Start the path with the given node
9,367
public function linkedTo ( string $ variable = null , array $ labels = [ ] ) : self { $ path = new self ; $ path -> elements = $ this -> elements -> add ( Relationship :: both ( ) ) -> add ( new Node ( $ variable , $ labels ) ) ; $ path -> lastOperation = Node :: class ; return $ path ; }
Create a relationship to the given node
9,368
public function through ( string $ variable = null , string $ type = null , string $ direction = 'BOTH' ) : self { if ( $ this -> elements -> size ( ) < 3 ) { throw new LogicException ; } $ direction = \ strtolower ( $ direction ) ; $ path = new self ; $ path -> elements = $ this -> elements -> dropEnd ( 2 ) -> add ( Relationship :: $ direction ( $ variable , $ type ) ) -> add ( $ this -> elements -> last ( ) ) ; $ path -> lastOperation = Relationship :: class ; return $ path ; }
Type the last declared relationship in the path
9,369
public function withADistanceOfAtLeast ( int $ distance ) : self { if ( $ this -> elements -> size ( ) < 3 ) { throw new LogicException ; } $ path = clone $ this ; $ path -> elements = $ this -> elements -> dropEnd ( 2 ) -> add ( $ this -> elements -> dropEnd ( 1 ) -> last ( ) -> withADistanceOfAtLeast ( $ distance ) ) -> add ( $ this -> elements -> last ( ) ) ; return $ path ; }
Define the minimum deepness of the relationship
9,370
public function withParameter ( string $ key , $ value ) : self { if ( $ this -> lastOperation === Node :: class ) { $ element = $ this -> elements -> last ( ) ; } else { $ element = $ this -> elements -> dropEnd ( 1 ) -> last ( ) ; } $ element = $ element -> withParameter ( $ key , $ value ) ; $ path = new self ; $ path -> lastOperation = $ this -> lastOperation ; if ( $ this -> lastOperation === Node :: class ) { $ path -> elements = $ this -> elements -> dropEnd ( 1 ) -> add ( $ element ) ; } else { $ path -> elements = $ this -> elements -> dropEnd ( 2 ) -> add ( $ element ) -> add ( $ this -> elements -> last ( ) ) ; } return $ path ; }
Add the given parameter to the last operation
9,371
public function withProperty ( string $ property , string $ cypher ) : self { if ( $ this -> lastOperation === Node :: class ) { $ element = $ this -> elements -> last ( ) ; } else { $ element = $ this -> elements -> dropEnd ( 1 ) -> last ( ) ; } $ element = $ element -> withProperty ( $ property , $ cypher ) ; $ path = new self ; $ path -> lastOperation = $ this -> lastOperation ; if ( $ this -> lastOperation === Node :: class ) { $ path -> elements = $ this -> elements -> dropEnd ( 1 ) -> add ( $ element ) ; } else { $ path -> elements = $ this -> elements -> dropEnd ( 2 ) -> add ( $ element ) -> add ( $ this -> elements -> last ( ) ) ; } return $ path ; }
Add the given property to the last operation
9,372
public function parameters ( ) : MapInterface { if ( $ this -> parameters ) { return $ this -> parameters ; } return $ this -> parameters = $ this -> elements -> reduce ( new Map ( 'string' , Parameter :: class ) , function ( Map $ carry , $ element ) : Map { return $ carry -> merge ( $ element -> parameters ( ) ) ; } ) ; }
Return all the parameters of the path
9,373
private function executeFFmpegForMedia ( $ cmd , $ format , $ resolution , $ media ) { $ ffmpeg_start = microtime ( true ) ; $ this -> getContainer ( ) -> get ( 'oktolab_media_ffmpeg' ) -> executeFFmpegForMedia ( $ resolution [ 'encoder' ] , $ cmd , $ media ) ; $ ffmpeg_stop = microtime ( true ) ; $ media -> setStatus ( Media :: OKTOLAB_MEDIA_STATUS_MEDIA_FINISHED ) ; $ media -> setPublic ( $ resolution [ 'public' ] ) ; $ this -> em -> persist ( $ media ) ; $ this -> em -> flush ( ) ; $ this -> logbook -> info ( 'oktolab_media.episode_end_saving_media' , [ '%format%' => $ format , '%seconds%' => round ( $ ffmpeg_stop - $ ffmpeg_start ) ] , $ this -> args [ 'uniqID' ] ) ; $ this -> getContainer ( ) -> get ( 'bprs.asset' ) -> moveAsset ( $ media -> getAsset ( ) , $ resolution [ 'adapter' ] ? $ resolution [ 'adapter' ] : $ media -> getEpisode ( ) -> getVideo ( ) -> getAdapter ( ) ) ; if ( ! $ this -> added_finalize ) { $ this -> finalizeEpisode ( $ media -> getEpisode ( ) ) ; $ this -> added_finalize = true ; } }
creates a media object and runs the ffmpeg command for the given resolution . the command will be tracked to update the progress from 0 - 100 in realtime . will move the asset from the cache adapter to the adapter in the resolution if defined . triggers the finalize episode function once for the whole job
9,374
private function finalizeEpisode ( $ episode ) { $ event = new EncodedEpisodeEvent ( $ episode ) ; $ this -> getContainer ( ) -> get ( 'event_dispatcher' ) -> dispatch ( OktolabMediaEvent :: ENCODED_EPISODE , $ event ) ; $ this -> oktolab_media -> addFinalizeEpisodeJob ( $ episode -> getUniqID ( ) , false , true ) ; }
adds finalize job and dispatches encoded_episode event
9,375
private function createNewCacheAssetForResolution ( $ episode , $ resolution ) { $ asset = $ this -> getContainer ( ) -> get ( 'bprs.asset' ) -> createAsset ( ) ; $ asset -> setFilekey ( sprintf ( '%s.%s' , $ asset -> getFilekey ( ) , $ resolution [ 'container' ] ) ) ; $ asset -> setAdapter ( $ this -> getContainer ( ) -> getParameter ( 'oktolab_media.encoding_filesystem' ) ) ; $ asset -> setName ( $ episode -> getVideo ( ) -> getName ( ) ) ; $ asset -> setMimetype ( $ resolution [ 'mimetype' ] ) ; return $ asset ; }
returns an empty asset to be used in an encoding situation . the filekey mimetype and adapter are already set for ffmpeg
9,376
public function withScope ( $ scope ) { if ( $ scope == Grid \ Exporter :: SCOPE_ALL ) { return $ this ; } list ( $ scope , $ args ) = explode ( ':' , $ scope ) ; if ( $ scope == Grid \ Exporter :: SCOPE_CURRENT_PAGE ) { $ this -> grid -> model ( ) -> usePaginate ( true ) ; } if ( $ scope == Grid \ Exporter :: SCOPE_SELECTED_ROWS ) { $ selected = explode ( ',' , $ args ) ; $ this -> grid -> model ( ) -> whereIn ( $ this -> grid -> getKeyName ( ) , $ selected ) ; } return $ this ; }
Export data with scope .
9,377
public function create ( array $ attributes ) { $ model = $ this -> getModelName ( ) ; $ nodeType = $ model :: create ( $ attributes ) ; $ this -> builderService -> buildTable ( $ nodeType -> getName ( ) , $ nodeType -> getKey ( ) ) ; return $ nodeType ; }
Creates a node type
9,378
public function destroy ( $ id ) { $ model = $ this -> getModelName ( ) ; $ nodeType = $ model :: findOrFail ( $ id ) ; $ this -> builderService -> destroyTable ( $ nodeType -> getName ( ) , $ nodeType -> getFieldKeys ( ) , $ nodeType -> getKey ( ) ) ; $ nodeType -> delete ( ) ; return $ nodeType ; }
Destroys a node type
9,379
public function getNodeTypesByIds ( $ ids ) { if ( empty ( $ ids ) ) { return null ; } if ( is_string ( $ ids ) ) { $ ids = json_decode ( $ ids , true ) ; } if ( is_array ( $ ids ) && ! empty ( $ ids ) ) { $ model = $ this -> getModelName ( ) ; $ placeholders = implode ( ',' , array_fill ( 0 , count ( $ ids ) , '?' ) ) ; $ nodeTypes = $ model :: whereIn ( 'id' , $ ids ) -> orderByRaw ( 'field(id,' . $ placeholders . ')' , $ ids ) -> get ( ) ; return ( count ( $ nodeTypes ) > 0 ) ? $ nodeTypes : null ; } return null ; }
Returns node types by ids
9,380
public function validate ( ) { try { Yaml \ Yaml :: parse ( $ this -> data ) ; } catch ( \ Exception $ e ) { return false ; } return true ; }
Validates a Yaml string
9,381
public function configureComposerJson ( Event $ event ) { static :: $ plugin -> getInstanceOf ( ComposerConfigurator :: class ) -> configure ( $ event -> getComposer ( ) , $ event -> getIO ( ) ) ; }
Configure the composer sonfiguration file .
9,382
public function setWordPressInstallDirectory ( PackageEvent $ event ) { if ( $ this -> getPackageName ( $ event ) != 'johnpbloch/wordpress' ) { return ; } $ composer = $ event -> getComposer ( ) ; $ rootPkg = $ composer -> getPackage ( ) ; if ( ! $ rootPkg ) { return ; } $ extra = $ rootPkg -> getExtra ( ) ; if ( isset ( $ extra [ 'wordpress-install-dir' ] ) && $ extra [ 'wordpress-install-dir' ] ) { return ; } $ extra [ 'wordpress-install-dir' ] = static :: $ plugin -> getPublicDirectory ( ) . '/wp' ; $ rootPkg -> setExtra ( $ extra ) ; $ composer -> setPackage ( $ rootPkg ) ; }
Set the WordPress installation directory .
9,383
public function cleanWordPressInstallation ( PackageEvent $ event ) { if ( $ this -> getPackageName ( $ event ) != 'johnpbloch/wordpress' ) { return ; } static :: $ plugin -> getInstanceOf ( WordPressInstallationCleaner :: class ) -> clean ( $ event -> getComposer ( ) , $ event -> getIO ( ) ) ; }
Clean the WordPress installation .
9,384
public function activateWordPressPlugin ( PackageEvent $ event ) { if ( ! $ this -> isWordPressPlugin ( $ this -> getPackage ( $ event ) ) ) { return ; } static :: $ plugin -> getInstanceOf ( PluginInteractor :: class ) -> activate ( $ event -> getComposer ( ) , $ event -> getIO ( ) , preg_replace ( '/^wpackagist-plugin\//' , '' , $ this -> getPackageName ( $ event ) ) ) ; }
Activate a WordPress plugin .
9,385
public function deactivateWordPressPlugin ( PackageEvent $ event ) { if ( ! $ this -> isWordPressPlugin ( $ this -> getPackage ( $ event ) ) ) { return ; } static :: $ plugin -> getInstanceOf ( PluginInteractor :: class ) -> deactivate ( $ event -> getComposer ( ) , $ event -> getIO ( ) , preg_replace ( '/^wpackagist-plugin\//' , '' , $ this -> getPackageName ( $ event ) ) ) ; }
Deactivate a WordPress plugin .
9,386
public function uninstallWordPressPlugin ( PackageEvent $ event ) { if ( ! $ this -> isWordPressPlugin ( $ this -> getPackage ( $ event ) ) ) { return ; } static :: $ plugin -> getInstanceOf ( PluginInteractor :: class ) -> uninstall ( $ event -> getComposer ( ) , $ event -> getIO ( ) , preg_replace ( '/^wpackagist-plugin\//' , '' , $ this -> getPackageName ( $ event ) ) ) ; }
Uninstall a WordPress plugin .
9,387
protected function getPackage ( PackageEvent $ event ) { $ operation = $ event -> getOperation ( ) ; if ( method_exists ( $ operation , 'getPackage' ) ) { return $ operation -> getPackage ( ) ; } return $ operation -> getTargetPackage ( ) ; }
Get the PackageInterface from a PackageEvent .
9,388
public function loadMetadataForClass ( \ ReflectionClass $ class ) { $ classMetadata = new ClassMetadata ( $ class -> name ) ; $ classMetadata -> fileResources [ ] = $ class -> getFileName ( ) ; foreach ( $ this -> reader -> getClassAnnotations ( $ class ) as $ annotation ) { if ( $ annotation instanceof NamespaceNode ) { $ classMetadata -> addGraphNamespace ( $ annotation ) ; } if ( $ annotation instanceof GraphNode ) { $ classMetadata -> addGraphMetadata ( $ annotation , new MetadataValue ( $ annotation -> value ) ) ; } } foreach ( $ class -> getProperties ( ) as $ property ) { foreach ( $ this -> reader -> getPropertyAnnotations ( $ property ) as $ annotation ) { if ( $ annotation instanceof GraphNode ) { $ classMetadata -> addGraphMetadata ( $ annotation , new PropertyMetadata ( $ class -> name , $ property -> name ) ) ; } } } foreach ( $ class -> getMethods ( ) as $ method ) { foreach ( $ this -> reader -> getMethodAnnotations ( $ method ) as $ annotation ) { if ( $ annotation instanceof GraphNode ) { $ classMetadata -> addGraphMetadata ( $ annotation , new MethodMetadata ( $ class -> name , $ method -> name ) ) ; } } } return $ classMetadata ; }
Load metadata class
9,389
protected function getIndexKey ( $ element ) { $ key = $ element -> getFullyQualifiedStructuralElementName ( ) ; if ( $ element instanceof PropertyInterface ) { list ( $ fqcn , $ propertyName ) = explode ( '::' , $ key ) ; $ key = $ fqcn . '::$' . $ propertyName ; } return $ key ; }
Retrieves a key for the index for the provided element .
9,390
public function set ( $ index , $ item ) { $ this -> offsetSet ( $ index , $ this -> parser -> text ( $ item ) ) ; }
Sets a new object onto the collection or clear it using null .
9,391
public function register ( ) { $ this -> helper_callbacks = array ( ) ; $ arguments = func_get_args ( ) ; if ( count ( $ arguments ) > 0 ) { foreach ( $ arguments as $ argument ) { if ( $ argument instanceof Plugin ) { $ callback = $ argument -> getEventHelperCallback ( $ this -> getName ( ) ) ; if ( is_callable ( $ callback ) ) { $ this -> helper_callbacks [ ] = $ callback ; } } else if ( is_callable ( $ argument ) ) { $ this -> helper_callbacks [ ] = $ argument ; } } } return $ this ; }
register an array of plugins objects and allow the plugins to join the process of handling this event
9,392
public function start ( ) { $ result = array ( ) ; if ( count ( $ this -> helper_callbacks ) > 0 ) { foreach ( $ this -> helper_callbacks as $ callback ) { $ return_value = call_user_func_array ( $ callback , array ( $ this ) ) ; $ result [ ] = $ return_value ; } } return $ result ; }
start this event
9,393
private function executeHandles ( & $ active , & $ mrc , $ timeout = 1 ) { do { $ mrc = curl_multi_exec ( $ this -> multiHandle , $ active ) ; } while ( $ mrc == CURLM_CALL_MULTI_PERFORM && $ active ) ; $ this -> checkCurlResult ( $ mrc ) ; if ( $ active && $ mrc == CURLM_OK && curl_multi_select ( $ this -> multiHandle , $ timeout ) == - 1 ) { usleep ( 100 ) ; } }
Execute and select curl handles until there is activity
9,394
protected function removeErroredRequest ( RequestInterface $ request , \ Exception $ e = null , $ buffer = true ) { if ( $ buffer ) { $ this -> exceptions [ ] = array ( 'request' => $ request , 'exception' => $ e ) ; } $ this -> remove ( $ request ) ; $ this -> dispatch ( self :: MULTI_EXCEPTION , array ( 'exception' => $ e , 'all_exceptions' => $ this -> exceptions ) ) ; }
Remove a request that encountered an exception
9,395
protected function processResponse ( RequestInterface $ request , CurlHandle $ handle , array $ curl ) { $ handle -> updateRequestFromTransfer ( $ request ) ; $ curlException = $ this -> isCurlException ( $ request , $ handle , $ curl ) ; $ this -> removeHandle ( $ request ) ; if ( ! $ curlException ) { $ state = $ request -> setState ( RequestInterface :: STATE_COMPLETE , array ( 'handle' => $ handle ) ) ; if ( $ state != RequestInterface :: STATE_TRANSFER ) { $ this -> remove ( $ request ) ; } } else { $ state = $ request -> setState ( RequestInterface :: STATE_ERROR , array ( 'exception' => $ curlException ) ) ; if ( $ state != RequestInterface :: STATE_TRANSFER ) { $ this -> remove ( $ request ) ; } if ( $ state == RequestInterface :: STATE_ERROR ) { throw $ curlException ; } } }
Check for errors and fix headers of a request based on a curl response
9,396
protected function removeHandle ( RequestInterface $ request ) { if ( isset ( $ this -> handles [ $ request ] ) ) { $ handle = $ this -> handles [ $ request ] ; unset ( $ this -> handles [ $ request ] ) ; unset ( $ this -> resourceHash [ ( int ) $ handle -> getHandle ( ) ] ) ; curl_multi_remove_handle ( $ this -> multiHandle , $ handle -> getHandle ( ) ) ; $ handle -> close ( ) ; } }
Remove a curl handle from the curl multi object
9,397
protected function getTemplates ( InputInterface $ input ) { $ configurationHelper = $ this -> getHelper ( 'phpdocumentor_configuration' ) ; $ templates = $ input -> getOption ( 'template' ) ; if ( ! $ templates ) { $ templatesFromConfig = $ configurationHelper -> getConfigValueFromPath ( 'transformations/templates' ) ; foreach ( $ templatesFromConfig as $ template ) { $ templates [ ] = $ template -> getName ( ) ; } } if ( ! $ templates ) { $ templates = array ( 'clean' ) ; } return $ templates ; }
Retrieves the templates to be used by analyzing the options and the configuration .
9,398
public function loadTransformations ( Transformer $ transformer ) { $ configurationHelper = $ this -> getHelper ( 'phpdocumentor_configuration' ) ; $ received = array ( ) ; $ transformations = $ configurationHelper -> getConfigValueFromPath ( 'transformations/transformations' ) ; if ( is_array ( $ transformations ) ) { if ( isset ( $ transformations [ 'writer' ] ) ) { $ received [ ] = $ this -> createTransformation ( $ transformations ) ; } else { foreach ( $ transformations as $ transformation ) { if ( is_array ( $ transformation ) ) { $ received [ ] = $ this -> createTransformation ( $ transformations ) ; } } } } $ this -> appendReceivedTransformations ( $ transformer , $ received ) ; }
Load custom defined transformations .
9,399
protected function createTransformation ( array $ transformations ) { return new Transformation ( isset ( $ transformations [ 'query' ] ) ? $ transformations [ 'query' ] : '' , $ transformations [ 'writer' ] , isset ( $ transformations [ 'source' ] ) ? $ transformations [ 'source' ] : '' , isset ( $ transformations [ 'artifact' ] ) ? $ transformations [ 'artifact' ] : '' ) ; }
Create Transformation instance .