idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
56,600
public function createSurveyFromExisting ( $ surveyId , array $ data = [ ] ) { return $ this -> sendRequest ( $ this -> createRequest ( 'POST' , 'surveys' , [ ] , array_merge ( $ data , [ 'from_survey_id' => $ surveyId ] ) ) ) ; }
createSurveyFromTemplate - Create a new survey from an existing survey
56,601
public function getSurvey ( $ surveyId , $ includePages = false ) { if ( $ includePages ) { return $ this -> sendRequest ( $ this -> createRequest ( 'GET' , sprintf ( 'surveys/%d/details' , $ surveyId ) ) ) ; } else { return $ this -> sendRequest ( $ this -> createRequest ( 'GET' , sprintf ( 'surveys/%d' , $ surveyId ) ) ) ; } }
getSurvey - Get information on a survey
56,602
public function updateSurvey ( $ surveyId , array $ data = [ ] ) { return $ this -> sendRequest ( $ this -> createRequest ( 'PATCH' , sprintf ( 'surveys/%d' , $ surveyId ) , [ ] , $ data ) ) ; }
updateSurvey - Updates a survey
56,603
public function replaceSurvey ( $ surveyId , array $ data = [ ] ) { return $ this -> sendRequest ( $ this -> createRequest ( 'PUT' , sprintf ( 'surveys/%d' , $ surveyId ) , [ ] , $ data ) ) ; }
replaceSurvey - Replaces a survey
56,604
public function getSurveyPages ( $ surveyId , array $ filters = [ ] ) { return $ this -> sendRequest ( $ this -> createRequest ( 'GET' , sprintf ( 'surveys/%d/pages' , $ surveyId ) , [ 'query' => $ filters ] ) ) ; }
getSurveyPages - Gets all pages for a given survey
56,605
public function createSurveyPage ( $ surveyId , array $ data = [ ] ) { return $ this -> sendRequest ( $ this -> createRequest ( 'POST' , sprintf ( 'surveys/%d/pages' , $ surveyId ) , [ ] , $ data ) ) ; }
createSurveyPage - Creates a new survey page
56,606
public function getSurveyPage ( $ surveyId , $ pageId ) { return $ this -> sendRequest ( $ this -> createRequest ( 'GET' , sprintf ( 'surveys/%d/pages/%d' , $ surveyId , $ pageId ) ) ) ; }
getSurveyPage - Get a single survey page
56,607
public function updateSurveyPage ( $ surveyId , $ pageId , array $ data = [ ] ) { return $ this -> sendRequest ( $ this -> createRequest ( 'PATCH' , sprintf ( 'surveys/%d/pages/%d' , $ surveyId , $ pageId ) , [ ] , $ data ) ) ; }
updateSurveyPage - Updates a survey page
56,608
public function replaceSurveyPage ( $ surveyId , $ pageId , array $ data = [ ] ) { return $ this -> sendRequest ( $ this -> createRequest ( 'PUT' , sprintf ( 'surveys/%d/pages/%d' , $ surveyId , $ pageId ) , [ ] , $ data ) ) ; }
replaceSurveyPage - Replaces a survey page
56,609
public function deleteSurveyPage ( $ surveyId , $ pageId ) { return $ this -> sendRequest ( $ this -> createRequest ( 'DELETE' , sprintf ( 'surveys/%d/pages/%d' , $ surveyId , $ pageId ) ) ) ; }
deleteSurveyPage - Delete a survey page
56,610
public function getSurveyPageQuestions ( $ surveyId , $ pageId , array $ filters = [ ] ) { return $ this -> sendRequest ( $ this -> createRequest ( 'GET' , sprintf ( 'surveys/%d/pages/%d/questions' , $ surveyId , $ pageId ) , [ 'query' => $ filters ] ) ) ; }
getSurveyPageQuestions - Get questions for a given survey page
56,611
public function createSurveyPageQuestion ( $ surveyId , $ pageId , array $ data = [ ] ) { return $ this -> sendRequest ( $ this -> createRequest ( 'POST' , sprintf ( 'surveys/%d/pages/%d/questions' , $ surveyId , $ pageId ) , [ ] , $ data ) ) ; }
createSurveyPageQuestion - Create a questions for a given survey page
56,612
public function getSurveyPageQuestion ( $ surveyId , $ pageId , $ questionId ) { return $ this -> sendRequest ( $ this -> createRequest ( 'GET' , sprintf ( 'surveys/%d/pages/%d/questions/%d' , $ surveyId , $ pageId , $ questionId ) ) ) ; }
getSurveyPageQuestion - Get a single survey page question
56,613
public function updateSurveyPageQuestion ( $ surveyId , $ pageId , $ questionId , array $ data = [ ] ) { return $ this -> sendRequest ( $ this -> createRequest ( 'PATCH' , sprintf ( 'surveys/%d/pages/%d/questions/%d' , $ surveyId , $ pageId , $ questionId ) , [ ] , $ data ) ) ; }
updateSurveyPageQuestion - Update a survey page question
56,614
public function deleteSurveyPageQuestion ( $ surveyId , $ pageId , $ questionId ) { return $ this -> sendRequest ( $ this -> createRequest ( 'DELETE' , sprintf ( 'surveys/%d/pages/%d/questions/%d' , $ surveyId , $ pageId , $ questionId ) ) ) ; }
deleteSurveyPageQuestion - Delete a survey page question
56,615
protected function getEaster ( $ year ) { $ easter = new \ DateTime ( 'now' , $ this -> timezone ) ; $ easter -> setDate ( $ year , 3 , 21 ) ; $ easter -> setTime ( 0 , 0 , 0 ) ; $ easter -> modify ( '+' . \ easter_days ( $ year ) . 'days' ) ; return $ easter ; }
Provides a DateTime object that represents easter sunday for this year .
56,616
public function between ( \ DateTime $ start , \ DateTime $ end ) { $ start = clone $ start ; $ end = clone $ end ; $ start -> setTime ( 0 , 0 , 0 ) ; $ end -> setTime ( 0 , 0 , 0 ) ; $ startyear = ( int ) $ start -> format ( "Y" ) ; $ endyear = ( int ) $ end -> format ( "Y" ) ; $ holidays = array ( ) ; for ( $ y = $ startyear ; $ y <= $ endyear ; $ y ++ ) { $ holidays = array_merge ( $ holidays , $ this -> getHolidays ( $ y ) ) ; } return array_filter ( $ holidays , function ( \ DateTime $ dt ) use ( $ start , $ end ) { return $ dt >= $ start && $ dt <= $ end ; } ) ; }
Returns all holidays in the given time period .
56,617
protected function _escape_str ( $ str ) { $ str = $ this -> conn_id -> quote ( $ str ) ; return ( $ str [ 0 ] === "'" ) ? substr ( $ str , 1 , - 1 ) : $ str ; }
Platform - dependant string escape
56,618
protected function _insert_batch ( $ table , $ keys , $ values ) { if ( version_compare ( $ this -> version ( ) , '10' , '>=' ) ) { return parent :: _insert_batch ( $ table , $ keys , $ values ) ; } return ( $ this -> db -> db_debug ) ? $ this -> db -> display_error ( 'db_unsupported_feature' ) : FALSE ; }
Insert batch statement
56,619
public function getAPIByType ( $ type ) { switch ( $ type ) { case 'news_image' : $ api = self :: API_NEWS_IMAGE_UPLOAD ; break ; default : $ api = self :: API_UPLOAD ; } return $ api ; }
Get API by type .
56,620
protected function _fetch_object ( $ class_name = 'stdClass' ) { if ( ( $ row = $ this -> result_id -> fetchArray ( SQLITE3_ASSOC ) ) === FALSE ) { return FALSE ; } elseif ( $ class_name === 'stdClass' ) { return ( object ) $ row ; } $ class_name = new $ class_name ( ) ; foreach ( array_keys ( $ row ) as $ key ) { $ class_name -> $ key = $ row [ $ key ] ; } return $ class_name ; }
Result - object
56,621
protected function _prep_query ( $ sql ) { if ( $ this -> delete_hack === TRUE && preg_match ( '/^\s*DELETE\s+FROM\s+(\S+)\s*$/i' , $ sql ) ) { return trim ( $ sql ) . ' WHERE 1=1' ; } return $ sql ; }
Prep the query
56,622
protected function _attr_unique ( & $ attributes , & $ field ) { if ( ! empty ( $ attributes [ 'UNIQUE' ] ) && $ attributes [ 'UNIQUE' ] === TRUE ) { $ field [ 'unique' ] = ' UNIQUE CONSTRAINT ' . $ this -> db -> escape_identifiers ( $ field [ 'name' ] ) ; } }
Field attribute UNIQUE
56,623
protected function checkAndThrow ( array $ contents ) { if ( isset ( $ contents [ 'errcode' ] ) && 0 !== $ contents [ 'errcode' ] ) { if ( empty ( $ contents [ 'errmsg' ] ) ) { $ contents [ 'errmsg' ] = 'Unknown' ; } throw new HttpException ( $ contents [ 'errmsg' ] , $ contents [ 'errcode' ] ) ; } }
Check the array data errors and Throw exception when the contents contains error .
56,624
protected function _attr_auto_increment ( & $ attributes , & $ field ) { if ( ! empty ( $ attributes [ 'AUTO_INCREMENT' ] ) && $ attributes [ 'AUTO_INCREMENT' ] === TRUE ) { if ( stripos ( $ field [ 'type' ] , 'int' ) !== FALSE ) { $ field [ 'auto_increment' ] = ' AUTO_INCREMENT' ; } elseif ( strcasecmp ( $ field [ 'type' ] , 'UUID' ) === 0 ) { $ field [ 'auto_increment' ] = ' AUTO_GENERATE' ; } } }
Field attribute AUTO_INCREMENT
56,625
protected function _list_columns ( $ table = '' ) { return 'SELECT "colname" FROM "syscat"."columns" WHERE LOWER("tabschema") = ' . $ this -> escape ( strtolower ( $ this -> database ) ) . ' AND LOWER("tabname") = ' . $ this -> escape ( strtolower ( $ table ) ) ; }
Show column query
56,626
public function read ( $ sql ) { $ segment_one = ( $ this -> CI -> uri -> segment ( 1 ) == FALSE ) ? 'default' : $ this -> CI -> uri -> segment ( 1 ) ; $ segment_two = ( $ this -> CI -> uri -> segment ( 2 ) == FALSE ) ? 'index' : $ this -> CI -> uri -> segment ( 2 ) ; $ filepath = $ this -> db -> cachedir . $ segment_one . '+' . $ segment_two . '/' . md5 ( $ sql ) ; if ( FALSE === ( $ cachedata = @ file_get_contents ( $ filepath ) ) ) { return FALSE ; } return unserialize ( $ cachedata ) ; }
Retrieve a cached query
56,627
public function write ( $ sql , $ object ) { $ segment_one = ( $ this -> CI -> uri -> segment ( 1 ) == FALSE ) ? 'default' : $ this -> CI -> uri -> segment ( 1 ) ; $ segment_two = ( $ this -> CI -> uri -> segment ( 2 ) == FALSE ) ? 'index' : $ this -> CI -> uri -> segment ( 2 ) ; $ dir_path = $ this -> db -> cachedir . $ segment_one . '+' . $ segment_two . '/' ; $ filename = md5 ( $ sql ) ; if ( ! is_dir ( $ dir_path ) && ! @ mkdir ( $ dir_path , 0750 ) ) { return FALSE ; } if ( write_file ( $ dir_path . $ filename , serialize ( $ object ) ) === FALSE ) { return FALSE ; } chmod ( $ dir_path . $ filename , 0640 ) ; return TRUE ; }
Write a query to a cache file
56,628
public function delete ( $ segment_one = '' , $ segment_two = '' ) { if ( $ segment_one === '' ) { $ segment_one = ( $ this -> CI -> uri -> segment ( 1 ) == FALSE ) ? 'default' : $ this -> CI -> uri -> segment ( 1 ) ; } if ( $ segment_two === '' ) { $ segment_two = ( $ this -> CI -> uri -> segment ( 2 ) == FALSE ) ? 'index' : $ this -> CI -> uri -> segment ( 2 ) ; } $ dir_path = $ this -> db -> cachedir . $ segment_one . '+' . $ segment_two . '/' ; delete_files ( $ dir_path , TRUE ) ; }
Delete cache files within a particular directory
56,629
public function temporary ( $ sceneId , $ expireSeconds = null ) { $ scene = [ 'scene_id' => intval ( $ sceneId ) ] ; return $ this -> create ( self :: SCENE_QR_TEMPORARY , $ scene , true , $ expireSeconds ) ; }
Create temporary .
56,630
protected function create ( $ actionName , $ actionInfo , $ temporary = true , $ expireSeconds = null ) { $ expireSeconds !== null || $ expireSeconds = 7 * self :: DAY ; $ params = [ 'action_name' => $ actionName , 'action_info' => [ 'scene' => $ actionInfo ] , ] ; if ( $ temporary ) { $ params [ 'expire_seconds' ] = min ( $ expireSeconds , 30 * self :: DAY ) ; } return $ this -> json ( self :: API_CREATE , $ params ) ; }
Create a QRCode .
56,631
public static function fromArray ( array $ data , $ filter = false ) { $ class = get_called_class ( ) ; $ object = new static ( ) ; foreach ( $ data as $ key => $ value ) { if ( ! $ filter || property_exists ( $ class , $ key ) ) { $ object -> $ key = $ value ; } } return $ object ; }
Create a Struct from an associative array
56,632
public function reload ( ) { if ( file_exists ( $ this -> lock_file ) ) { unlink ( $ this -> lock_file ) ; } $ this -> composer = $ this -> factory -> createComposer ( $ this -> getIO ( ) ) ; }
Reload Composer .
56,633
public static function getVersionCompatible ( $ version ) { $ suffixes = [ 'dev' => 1 , 'patch' => 2 , 'alpha' => 3 , 'beta' => 4 , 'stable' => 5 , 'rc' => 6 , ] ; $ reg = '/^v?(?<version>\d+\.\d+\.\d+)(?:-(?<suffix>dev|patch|alpha|beta|rc)(?<suffix_version>\d+)?)?$/i' ; if ( ! preg_match ( $ reg , $ version , $ match ) ) { return false ; } if ( isset ( $ match [ 'suffix' ] ) ) { $ suffix = $ suffixes [ strtolower ( $ match [ 'suffix' ] ) ] . '.' ; $ suffix .= isset ( $ match [ 'suffix_version' ] ) ? ( int ) $ match [ 'suffix_version' ] : 1 ; } else { $ suffix = $ suffixes [ 'stable' ] . '.0' ; } return $ match [ 'version' ] . '.' . $ suffix ; }
Get version compatible .
56,634
public static function packageInKernel ( PackageEvent $ event ) { self :: addJobByOperationType ( $ event -> getOperation ( ) , function ( $ package ) { return new AddKernel ( $ package ) ; } , function ( $ package ) { return new RemoveKernel ( $ package ) ; } ) ; }
Add or remove package in kernel .
56,635
public static function packageInRouting ( PackageEvent $ event ) { self :: addJobByOperationType ( $ event -> getOperation ( ) , function ( $ package ) { return new AddRouting ( $ package ) ; } , function ( $ package ) { return new RemoveRouting ( $ package ) ; } ) ; }
Add or remove packages in routing .
56,636
public static function packageInConfig ( PackageEvent $ event ) { self :: addJobByOperationType ( $ event -> getOperation ( ) , function ( $ package ) { return new AddConfig ( $ package ) ; } , function ( $ package ) { return new RemoveConfig ( $ package ) ; } ) ; }
Add or remove packages in config .
56,637
public static function migratePackage ( PackageEvent $ event ) { self :: addJobByOperationType ( $ event -> getOperation ( ) , function ( $ package ) { return new UpMigrate ( $ package ) ; } , function ( $ package ) { return new DownMigrate ( $ package ) ; } ) ; }
Migrate packages .
56,638
protected static function addJobByOperationType ( OperationInterface $ operation , \ Closure $ install , \ Closure $ uninstall , \ Closure $ update = null ) { switch ( $ operation -> getJobType ( ) ) { case 'install' : self :: getContainer ( ) -> addJob ( $ install ( $ operation -> getPackage ( ) ) ) ; break ; case 'uninstall' : self :: getContainer ( ) -> addJob ( $ uninstall ( $ operation -> getPackage ( ) ) ) ; break ; case 'update' : $ update = $ update ? : $ install ; self :: getContainer ( ) -> addJob ( $ update ( $ operation -> getTargetPackage ( ) ) ) ; break ; } }
Add job by operation type .
56,639
public static function notifyProjectInstall ( Event $ event ) { self :: getContainer ( ) -> addJob ( new InstalledProjectNotify ( $ event -> getComposer ( ) -> getPackage ( ) ) ) ; }
Notify listeners that the project has been installed .
56,640
public static function notifyProjectUpdate ( Event $ event ) { self :: getContainer ( ) -> addJob ( new UpdatedProjectNotify ( $ event -> getComposer ( ) -> getPackage ( ) ) ) ; }
Notify listeners that the project has been updated .
56,641
public static function installConfig ( ) { if ( ! file_exists ( self :: getRootDir ( ) . 'config/vendor_config.yml' ) ) { file_put_contents ( self :: getRootDir ( ) . 'config/vendor_config.yml' , '' ) ; } if ( ! file_exists ( self :: getRootDir ( ) . 'config/routing.yml' ) ) { file_put_contents ( self :: getRootDir ( ) . 'config/routing.yml' , '' ) ; } if ( ! file_exists ( self :: getRootDir ( ) . 'bundles.php' ) ) { file_put_contents ( self :: getRootDir ( ) . 'bundles.php' , "<?php\nreturn [\n];" ) ; } if ( file_exists ( self :: getRootDir ( ) . '/../bin/php/php.ini' ) ) { $ manipulator = self :: getContainer ( ) -> getManipulator ( 'php.ini' ) ; $ limit = $ manipulator -> get ( 'memory_limit' ) ? : '1G' ; $ limit = is_array ( $ limit ) ? array_pop ( $ limit ) : $ limit ; if ( $ manipulator -> byteStringToInt ( $ limit ) < 1073741824 ) { $ manipulator -> set ( 'memory_limit' , '1G' ) ; } } }
Install config files .
56,642
public static function generateSecretKey ( ) { touch ( self :: getRootDir ( ) . '/config/parameters.yml' ) ; $ manipulator = self :: getContainer ( ) -> getManipulator ( 'parameters' ) ; if ( ! $ manipulator -> get ( 'secret' ) ) { $ manipulator -> set ( 'secret' , SecretKey :: generate ( ) ) ; } }
Make a unique secret key .
56,643
public static function migrateUp ( Event $ event ) { $ dir = self :: getRootDir ( ) . 'DoctrineMigrations' ; if ( self :: isHaveMigrations ( $ dir ) ) { self :: repackMigrations ( $ dir ) ; self :: executeCommand ( 'doctrine:migrations:migrate --no-interaction' , $ event -> getIO ( ) ) ; } }
Migrate all plugins to up .
56,644
public static function migrateDown ( Event $ event ) { $ dir = self :: getRootDir ( ) . 'cache/dev/DoctrineMigrations/' ; if ( self :: isHaveMigrations ( $ dir ) ) { file_put_contents ( $ dir . 'migrations.yml' , "migrations_namespace: 'Application\Migrations'\n" . "migrations_directory: 'app/cache/dev/DoctrineMigrations/'\n" . "table_name: 'migration_versions'" ) ; self :: executeCommand ( 'doctrine:migrations:migrate --no-interaction --configuration=' . $ dir . 'migrations.yml 0' , $ event -> getIO ( ) ) ; } }
Migrate all plugins to down .
56,645
public function add ( $ url , $ description = NULL , array $ events = array ( ) ) { return $ this -> request ( 'add' , array ( 'url' => $ url , 'description' => $ description , 'events' => $ events ) ) ; }
Add a new webhook
56,646
public function update ( $ id , $ url , $ description = NULL , array $ events = array ( ) ) { return $ this -> request ( 'update' , array ( 'id' => $ id , 'url' => $ url , 'description' => $ description , 'events' => $ events ) ) ; }
Update an existing webhook
56,647
public function activity ( $ notifyEmail = NULL , $ dateFrom = NULL , $ dateTo = NULL , array $ tags = array ( ) , array $ senders = array ( ) , array $ states = array ( ) , array $ apiKeys = array ( ) ) { return $ this -> request ( 'activity' , array ( 'notify_email' => $ notifyEmail , 'date_from' => $ dateFrom , 'date_to' => $ dateTo , 'tags' => $ tags , 'senders' => $ senders , 'states' => $ states , 'api_keys' => $ apiKeys ) ) ; }
Begins an export of your activity history .
56,648
protected function getMemcached ( $ connectionId , array $ credentials , array $ options ) { $ memcached = $ this -> createMemcachedInstance ( $ connectionId ) ; if ( count ( $ credentials ) == 2 ) { $ this -> setCredentials ( $ memcached , $ credentials ) ; } if ( count ( $ options ) ) { $ memcached -> setOptions ( $ options ) ; } return $ memcached ; }
Get a new Memcached instance .
56,649
protected function setCredentials ( $ memcached , $ credentials ) { list ( $ username , $ password ) = $ credentials ; $ memcached -> setOption ( Memcached :: OPT_BINARY_PROTOCOL , true ) ; $ memcached -> setSaslAuthData ( $ username , $ password ) ; }
Set the SASL credentials on the Memcached connection .
56,650
public function add ( $ id , $ name = NULL , $ notes = NULL , $ customQuota = NULL ) { return $ this -> request ( 'add' , array ( 'id' => $ id , 'name' => $ name , 'notes' => $ notes , 'custom_quota' => $ customQuota ) ) ; }
Add a new subaccount
56,651
public function update ( $ id , $ name = NULL , $ notes = NULL , $ customQuota = NULL ) { return $ this -> request ( 'update' , array ( 'id' => $ id , 'name' => $ name , 'notes' => $ notes , 'custom_quota' => $ customQuota ) ) ; }
Update an existing subaccount
56,652
protected function request ( $ url , array $ body = array ( ) ) { $ baseUrl = self :: BASE_URL ; if ( isset ( $ this -> baseUrl ) ) { $ baseUrl = $ this -> baseUrl ; } $ client = new Client ( $ baseUrl ) ; $ body [ 'key' ] = $ this -> apiKey ; $ section = explode ( '\\' , get_called_class ( ) ) ; $ section = strtolower ( end ( $ section ) ) ; $ request = $ client -> post ( $ section . '/' . $ url . '.json' , NULL , $ body ) ; try { $ response = $ request -> send ( ) ; $ response = $ response -> getBody ( ) ; } catch ( ServerErrorResponseException $ e ) { $ response = json_decode ( $ e -> getResponse ( ) -> getBody ( ) , true ) ; throw new APIException ( $ response [ 'message' ] , $ response [ 'code' ] , $ response [ 'status' ] , $ response [ 'name' ] , $ e ) ; } return json_decode ( $ response , true ) ; }
Send a request to Mandrill . All requests are sent via HTTP POST .
56,653
public function prerenderPage ( MvcEvent $ event ) { $ originalRequest = $ event -> getRequest ( ) ; if ( ! $ this -> shouldPrerenderPage ( $ originalRequest ) ) { return ; } $ event -> stopPropagation ( true ) ; $ eventManager = $ this -> getEventManager ( ) ; $ responses = $ eventManager -> trigger ( PrerenderEvent :: EVENT_PRERENDER_PRE , new PrerenderEvent ( $ originalRequest ) ) ; if ( $ responses -> last ( ) instanceof HttpResponse ) { return $ responses -> last ( ) ; } $ client = $ this -> getHttpClient ( ) ; $ uri = rtrim ( $ this -> moduleOptions -> getPrerenderUrl ( ) , '/' ) . '/' . $ originalRequest -> getUriString ( ) ; $ userAgent = $ originalRequest -> getHeaders ( ) -> get ( 'User-Agent' ) -> getFieldValue ( ) ; $ client -> setUri ( $ uri ) -> setMethod ( HttpRequest :: METHOD_GET ) ; $ request = $ client -> getRequest ( ) ; $ request -> getHeaders ( ) -> addHeaderLine ( 'User-Agent' , $ userAgent ) -> addHeaderLine ( 'Accept-Encoding' , 'gzip' ) ; if ( $ prerenderToken = $ this -> moduleOptions -> getPrerenderToken ( ) ) { $ request -> getHeaders ( ) -> addHeaderLine ( 'X-Prerender-Token' , $ prerenderToken ) ; } $ response = $ client -> send ( $ request ) ; $ prerenderEvent = new PrerenderEvent ( $ request , $ response ) ; $ eventManager -> trigger ( PrerenderEvent :: EVENT_PRERENDER_POST , $ prerenderEvent ) ; return $ prerenderEvent -> getResponse ( ) ; }
Pre - render the page
56,654
public function addBundle ( $ bundle ) { $ bundle = $ this -> getBundleString ( $ bundle ) ; if ( strpos ( $ this -> getKernal ( ) , $ bundle ) === false ) { $ bundles = $ this -> getBundles ( ) ; if ( ! in_array ( $ bundle , $ bundles ) ) { $ bundles [ ] = $ bundle ; $ this -> setBundles ( $ bundles ) ; } } }
Add bundle to kernal .
56,655
public function removeBundle ( $ bundle ) { $ bundles = $ this -> getBundles ( ) ; if ( ( $ key = array_search ( $ this -> getBundleString ( $ bundle ) , $ bundles ) ) !== false ) { unset ( $ bundles [ $ key ] ) ; $ this -> setBundles ( $ bundles ) ; } }
Remove bundle from kernal .
56,656
protected function getKernal ( ) { if ( ! $ this -> kernel ) { $ this -> kernel = file_get_contents ( $ this -> kernel_filename ) ; } return $ this -> kernel ; }
Get AppKernal content .
56,657
public function addPackage ( $ package , $ version ) { $ config = $ this -> getContent ( ) ; $ config [ 'require' ] [ $ package ] = $ version ; $ this -> setContent ( $ config ) ; }
Add the package into composer requirements .
56,658
public function removePackage ( $ package ) { $ config = $ this -> getContent ( ) ; if ( isset ( $ config [ 'require' ] [ $ package ] ) ) { unset ( $ config [ 'require' ] [ $ package ] ) ; $ this -> setContent ( $ config ) ; } }
Remove the package from composer requirements .
56,659
public function getPackageBundle ( ) { if ( ( $ class = $ this -> getPackageOption ( 'anime-db-bundle' ) ) && class_exists ( $ class ) ) { return $ class ; } $ name = preg_replace ( '/(\/.+)[^a-z]bundle$/i' , '$1' , $ this -> package -> getName ( ) ) ; $ name = preg_replace ( '/[^a-zA-Z\/]+/' , ' ' , $ name ) ; $ name = ucwords ( str_replace ( '/' , ' / ' , $ name ) ) ; list ( $ vendor , $ bundle ) = explode ( '/' , str_replace ( ' ' , '' , $ name ) , 2 ) ; $ classes = [ '\\' . $ vendor . '\Bundle\\' . $ bundle . 'Bundle\\' . $ vendor . $ bundle . 'Bundle' , '\\' . $ vendor . '\Bundle\\' . $ bundle . 'Bundle\\' . $ bundle . 'Bundle' , ] ; list ( , $ bundle ) = explode ( '/' , $ name , 2 ) ; $ bundle = trim ( $ bundle ) ; if ( ( $ pos = strpos ( $ bundle , ' ' ) ) !== false ) { $ vendor = substr ( $ bundle , 0 , $ pos ) ; $ bundle = str_replace ( ' ' , '' , substr ( $ bundle , $ pos + 1 ) ) ; $ classes [ ] = '\\' . $ vendor . '\Bundle\\' . $ bundle . 'Bundle\\' . $ vendor . $ bundle . 'Bundle' ; $ classes [ ] = '\\' . $ vendor . '\Bundle\\' . $ bundle . 'Bundle\\' . $ bundle . 'Bundle' ; } foreach ( $ classes as $ class ) { if ( class_exists ( $ class ) ) { $ options = $ this -> package -> getExtra ( ) ; $ options [ 'anime-db-bundle' ] = $ class ; $ this -> package -> setExtra ( $ options ) ; return $ class ; } } return ; }
Get the bundle from package .
56,660
public function getPackageCopy ( ) { $ copy = new Package ( $ this -> package -> getName ( ) , $ this -> package -> getVersion ( ) , $ this -> package -> getPrettyVersion ( ) ) ; $ copy -> setType ( $ this -> package -> getType ( ) ) ; $ copy -> setExtra ( $ this -> package -> getExtra ( ) ) ; return $ copy ; }
Get a simple copy of the package .
56,661
protected function getRoutingNodeName ( ) { $ name = strtolower ( $ this -> getPackage ( ) -> getName ( ) ) ; $ name = preg_replace ( '/(\/.+)[^a-z]bundle$/' , '$1' , $ name ) ; $ name = preg_replace ( '/[^a-z_]+/' , '_' , $ name ) ; return $ name ; }
Get the routing node name from the package name .
56,662
public function add ( $ name , $ fromEmail = NULL , $ fromName = NULL , $ subject = NULL , $ code = NULL , $ text = NULL , $ publish = true ) { return $ this -> request ( 'add' , array ( 'name' => $ name , 'from_email' => $ fromEmail , 'from_name' => $ fromName , 'subject' => $ subject , 'code' => $ code , 'text' => $ text , 'publish' => $ publish ) ) ; }
Add a new template
56,663
public function sendRaw ( $ rawMessage , array $ to = array ( ) , $ mailFrom = NULL , $ helo = NULL , $ clientAddress = NULL ) { return $ this -> request ( 'send-raw' , array ( 'raw_message' => $ rawMessage , 'to' => $ to , 'mail_from' => $ mailFrom , 'helo' => $ helo , 'client_address' => $ clientAddress ) ) ; }
Take a raw MIME document destined for a domain with inbound domains set up and send it to the inbound hook exactly as if it had been sent over SMTP
56,664
protected function rewriting ( $ from ) { $ fs = $ this -> getContainer ( ) -> get ( 'filesystem' ) ; try { $ fs -> remove ( Finder :: create ( ) -> files ( ) -> ignoreUnreadableDirs ( ) -> in ( $ this -> getContainer ( ) -> getParameter ( 'kernel.root_dir' ) . '/../src' ) -> in ( $ this -> getContainer ( ) -> getParameter ( 'kernel.root_dir' ) ) ) ; } catch ( \ Exception $ e ) { } $ fs -> mirror ( $ from , $ this -> getContainer ( ) -> getParameter ( 'kernel.root_dir' ) . '/../' , null , [ 'override' => true , 'copy_on_windows' => true ] ) ; $ fs -> remove ( $ from ) ; }
Rewrite the application files .
56,665
public function setGlobalMergeVars ( array $ vars ) { $ this -> global_merge_vars = array ( ) ; foreach ( $ vars as $ name => $ content ) { $ this -> addGlobalMergeVar ( $ name , $ content ) ; } return $ this ; }
Set all global merge variables . Will overwrite any currently set global merge variables .
56,666
public function addRecipient ( Recipient $ recipient ) { $ this -> to [ ] = array ( 'email' => $ recipient -> email , 'name' => $ recipient -> name , 'type' => $ recipient -> type ) ; $ this -> merge_vars [ ] = array ( 'rcpt' => $ recipient -> email , 'vars' => $ recipient -> getMergeVars ( ) ) ; $ this -> recipient_metadata [ ] = array ( 'rcpt' => $ recipient -> email , 'values' => $ recipient -> getMetadata ( ) ) ; return $ this ; }
Add a recipient to this message
56,667
public function execute ( ) { $ jobs = [ ] ; ksort ( $ this -> jobs ) ; foreach ( $ this -> jobs as $ priority_jobs ) { $ jobs = array_merge ( $ jobs , $ priority_jobs ) ; } foreach ( $ jobs as $ job ) { $ job -> execute ( ) ; } }
Execute all jobs .
56,668
public function load ( ) { $ this -> outputTitle ( 'Loading predefined workers' ) ; $ debug = $ this -> debug ; if ( ! isset ( $ this -> runtime [ 'Queues' ] ) || empty ( $ this -> runtime [ 'Queues' ] ) ) { $ this -> output -> outputLine ( "You have no configured workers to load.\n" , 'failure' ) ; } else { $ this -> output -> outputLine ( sprintf ( 'Loading %s workers' , count ( $ this -> runtime [ 'Queues' ] ) ) ) ; $ config = $ this -> config ; foreach ( $ this -> runtime [ 'Queues' ] as $ queue ) { $ queue [ 'config' ] = $ config ; $ queue [ 'debug' ] = $ debug ; $ this -> loadSettings ( 'load' , $ queue ) ; $ this -> start ( $ this -> runtime ) ; } } if ( $ this -> runtime [ 'Scheduler' ] [ 'enabled' ] === true ) { $ this -> startscheduler ( array ( 'debug' => $ debug ) ) ; } $ this -> output -> outputLine ( ) ; }
Load workers from configuration
56,669
public function restart ( ) { $ workers = $ this -> ResqueStatus -> getWorkers ( ) ; $ this -> outputTitle ( 'Restarting workers' ) ; if ( ! empty ( $ workers ) ) { $ this -> stop ( ) ; foreach ( $ workers as $ worker ) { if ( isset ( $ worker [ 'type' ] ) && $ worker [ 'type' ] === 'scheduler' ) { $ this -> startScheduler ( $ worker ) ; } else { $ this -> start ( $ worker ) ; } } } else { $ this -> output -> outputLine ( 'No workers to restart' , 'failure' ) ; } $ this -> output -> outputLine ( ) ; }
Restart all workers
56,670
public function tail ( ) { $ logs = array ( ) ; $ i = 1 ; $ workers = $ this -> ResqueStatus -> getWorkers ( ) ; foreach ( $ workers as $ worker ) { if ( $ worker [ 'Log' ] [ 'filename' ] != '' ) { $ logs [ ] = $ worker [ 'Log' ] [ 'filename' ] ; } if ( $ worker [ 'Log' ] [ 'handler' ] == 'RotatingFile' ) { $ fileInfo = pathinfo ( $ worker [ 'Log' ] [ 'target' ] ) ; $ pattern = $ fileInfo [ 'dirname' ] . DS . $ fileInfo [ 'filename' ] . '-*' . ( ! empty ( $ fileInfo [ 'extension' ] ) ? '.' . $ fileInfo [ 'extension' ] : '' ) ; $ logs = array_merge ( $ logs , glob ( $ pattern ) ) ; } } $ logs = array_values ( array_unique ( $ logs ) ) ; $ this -> outputTitle ( 'Tailing log file' ) ; if ( empty ( $ logs ) ) { $ this -> output -> outputLine ( 'No log file to tail' , 'failure' ) ; return ; } elseif ( count ( $ logs ) == 1 ) { $ index = 1 ; } else { $ menuOptions = new \ ezcConsoleMenuDialogOptions ( array ( 'text' => 'Log files list' , 'selectText' => 'Log to tail :' , 'validator' => new DialogMenuValidator ( array_combine ( range ( 1 , count ( $ logs ) ) , $ logs ) ) ) ) ; $ menuDialog = new \ ezcConsoleMenuDialog ( $ this -> output , $ menuOptions ) ; do { $ menuDialog -> display ( ) ; } while ( $ menuDialog -> hasValidResult ( ) === false ) ; $ index = $ menuDialog -> getResult ( ) ; } $ this -> output -> outputLine ( 'Tailing ' . $ logs [ $ index - 1 ] , 'subtitle' ) ; $ this -> tailCommand ( $ logs [ $ index - 1 ] ) ; }
Tail a log file
56,671
public function enqueue ( ) { $ this -> outputTitle ( 'Queuing a job' ) ; $ args = $ this -> input -> getArguments ( ) ; if ( count ( $ args ) >= 2 ) { $ queue = array_shift ( $ args ) ; $ class = array_shift ( $ args ) ; $ result = call_user_func_array ( self :: $ Resque . '::enqueue' , array ( $ queue , $ class , $ args ) ) ; $ this -> output -> outputLine ( 'The job was enqueued successfully' , 'success' ) ; $ this -> output -> outputLine ( 'Job ID : #' . $ result . "\n" ) ; } else { $ this -> output -> outputLine ( 'Enqueue takes at least 2 arguments' , 'failure' ) ; $ this -> output -> outputLine ( 'Usage : enqueue <queue> <job> <args>' ) ; $ this -> output -> outputLine ( ' queue <string> Name of the queue' ) ; $ this -> output -> outputLine ( ' job <string> Job class name' ) ; $ this -> output -> outputLine ( ' args <string> Comma separated list of arguments' ) ; $ this -> output -> outputLine ( ) ; } }
Add a job to a queue
56,672
public function reset ( ) { $ this -> debug ( 'Emptying the worker database' ) ; $ this -> ResqueStatus -> clearWorkers ( ) ; $ this -> debug ( 'Unregistering the scheduler worker' ) ; $ this -> ResqueStatus -> unregisterSchedulerWorker ( ) ; $ this -> output -> outputLine ( 'Fresque state has been reseted' , 'success' ) ; }
Reset worker statuses
56,673
public function outputTitle ( $ title , $ primary = true ) { $ l = strlen ( $ title ) ; if ( $ primary ) { $ this -> output -> outputLine ( str_repeat ( '-' , $ l ) , 'title' ) ; } $ this -> output -> outputLine ( $ title , $ primary ? 'title' : 'subtitle' ) ; if ( $ primary ) { $ this -> output -> outputLine ( str_repeat ( '-' , $ l ) , 'title' ) ; } }
Print a pretty title
56,674
public function formatDateDiff ( $ start , $ end = null ) { if ( ! ( $ start instanceof \ DateTime ) ) { $ start = new \ DateTime ( $ start ) ; } if ( $ end === null ) { $ end = new \ DateTime ( ) ; } if ( ! ( $ end instanceof \ DateTime ) ) { $ end = new \ DateTime ( $ start ) ; } $ interval = $ end -> diff ( $ start ) ; $ doPlural = function ( $ nb , $ str ) { return $ nb > 1 ? $ str . 's' : $ str ; } ; $ format = array ( ) ; if ( $ interval -> y !== 0 ) { $ format [ ] = '%y ' . $ doPlural ( $ interval -> y , 'year' ) ; } if ( $ interval -> m !== 0 ) { $ format [ ] = '%m ' . $ doPlural ( $ interval -> m , 'month' ) ; } if ( $ interval -> d !== 0 ) { $ format [ ] = '%d ' . $ doPlural ( $ interval -> d , 'day' ) ; } if ( $ interval -> h !== 0 ) { $ format [ ] = '%h ' . $ doPlural ( $ interval -> h , 'hour' ) ; } if ( $ interval -> i !== 0 ) { $ format [ ] = '%i ' . $ doPlural ( $ interval -> i , 'minute' ) ; } if ( $ interval -> s !== 0 ) { if ( ! count ( $ format ) ) { return 'less than a minute' ; } else { $ format [ ] = '%s ' . $ doPlural ( $ interval -> s , 'second' ) ; } } if ( count ( $ format ) > 1 ) { $ format = array_shift ( $ format ) . ' and ' . array_shift ( $ format ) ; } else { $ format = array_pop ( $ format ) ; } return $ interval -> format ( $ format ) ; }
A sweet interval formatting will use the two biggest interval parts . On small intervals you get minutes and seconds . On big intervals you get months and days . Only the two biggest parts are used .
56,675
private function absolutePath ( $ path ) { if ( substr ( $ path , 0 , 2 ) === './' ) { $ path = dirname ( __DIR__ ) . DS . substr ( $ path , 2 ) ; } elseif ( substr ( $ path , 0 , 1 ) !== '/' || substr ( $ path , 0 , 3 ) === '../' ) { $ path = dirname ( __DIR__ ) . DS . $ path ; } return rtrim ( $ path , DS ) ; }
Return the absolute path to a file
56,676
protected function getResqueBinFile ( $ base ) { $ paths = array ( 'bin' . DS . 'resque' , 'bin' . DS . 'resque.php' , 'resque.php' ) ; foreach ( $ paths as $ path ) { if ( file_exists ( $ base . DS . $ path ) ) { return '.' . DS . $ path ; } } return '.' . DS . 'resque.php' ; }
Return the php - resque executable file
56,677
protected function kill ( $ signal , $ pid ) { $ output = array ( ) ; $ message = exec ( sprintf ( ( $ this -> runtime [ 'Default' ] [ 'user' ] !== $ this -> getProcessOwner ( ) ? ( 'sudo -u ' . escapeshellarg ( $ this -> runtime [ 'Default' ] [ 'user' ] ) ) . ' ' : "" ) . '/bin/kill -%s %s 2>&1' , $ signal , $ pid ) , $ output , $ code ) ; return array ( 'code' => $ code , 'message' => $ message ) ; }
Send a signal to a process
56,678
protected function checkStartedWorker ( $ pidFile ) { $ pid = false ; if ( file_exists ( $ pidFile ) && false !== $ pid = file_get_contents ( $ pidFile ) ) { unlink ( $ pidFile ) ; return ( int ) $ pid ; } return false ; }
Check the content of the PID file created by the worker to retrieve its process PID
56,679
protected function getUserChoice ( $ listTitle , $ selectMessage , $ menuItems ) { $ menuOptions = new \ ezcConsoleMenuDialogOptions ( array ( 'text' => $ listTitle , 'selectText' => $ selectMessage , 'validator' => new DialogMenuValidator ( $ menuItems ) ) ) ; $ menuDialog = new \ ezcConsoleMenuDialog ( $ this -> output , $ menuOptions ) ; do { $ menuDialog -> display ( ) ; } while ( $ menuDialog -> hasValidResult ( ) === false ) ; return $ menuDialog -> getResult ( ) ; }
Display a Dialog menu and retrieve the user selection
56,680
public function setPool ( $ ip , $ pool , $ createPool = false ) { return $ this -> request ( 'set-pool' , array ( 'ip' => $ ip , 'pool' => $ pool , 'create_pool' => $ createPool ) ) ; }
Moves a dedicated IP to a different pool .
56,681
public function sendTemplate ( $ templateName , Message $ message , array $ templateContent = array ( ) , $ async = false , $ ipPool = NULL , $ sendAt = NULL ) { if ( ! sizeof ( $ templateContent ) ) { $ templateContent = array ( '' ) ; } return $ this -> request ( 'send-template' , array ( 'template_name' => $ templateName , 'template_content' => $ templateContent , 'message' => $ message -> toArray ( ) , 'async' => $ async , 'ip_pool' => $ ipPool , 'send_at' => $ sendAt ) ) ; }
Send a new transactional message through Mandrill using a template
56,682
public function search ( $ query = '*' , $ dateFrom = NULL , $ dateTo = NULL , array $ tags = array ( ) , array $ senders = array ( ) , array $ apiKeys = array ( ) , $ limit = 100 ) { return $ this -> request ( 'search' , array ( 'query' => $ query , 'date_from' => $ dateFrom , 'date_to' => $ dateTo , 'tags' => $ tags , 'senders' => $ senders , 'api_keys' => $ apiKeys , 'limit' => $ limit ) ) ; }
Search the content of recently sent messages and optionally narrow by date range tags and senders
56,683
public function searchTimeSeries ( $ query = '*' , $ dateFrom = NULL , $ dateTo = NULL , array $ tags = array ( ) , array $ senders = array ( ) ) { return $ this -> request ( 'search-time-series' , array ( 'query' => $ query , 'date_from' => $ dateFrom , 'date_to' => $ dateTo , 'tags' => $ tags , 'senders' => $ senders ) ) ; }
Search the content of recently sent messages and return the aggregated hourly stats for matching messages
56,684
public function sendRaw ( $ rawMessage , $ fromEmail = NULL , $ fromName = NULL , array $ to = array ( ) , $ async = false , $ ipPool = NULL , $ sendAt = NULL ) { return $ this -> request ( 'send-raw' , array ( 'raw_message' => $ rawMessage , 'from_email' => $ fromEmail , 'from_name' => $ fromName , 'to' => $ to , 'async' => $ async , 'ip_pool' => $ ipPool , 'send_at' => $ sendAt ) ) ; }
Take a raw MIME document for a message and send it exactly as if it were sent through Mandrill s SMTP servers
56,685
protected function encode ( array $ messages ) { if ( $ this -> encode ) { foreach ( $ messages as $ key => $ message ) { if ( ( $ form = mb_detect_encoding ( $ message ) ) != self :: TARGET_ENCODING ) { $ messages [ $ key ] = mb_convert_encoding ( $ message , self :: TARGET_ENCODING , $ form ) ; } } } return $ messages ; }
Encode messages .
56,686
public function register ( ) { parent :: register ( ) ; $ this -> app -> singleton ( 'cache' , function ( $ app ) { return new CacheManager ( $ app ) ; } ) ; $ this -> app -> singleton ( 'memcached.connector' , function ( ) { return new MemcachedConnector ( ) ; } ) ; }
Replace \ Illuminate \ Cache \ CacheManager with B3IT \ CacheManager .
56,687
protected function getMigrationsConfig ( ) { $ dir = $ this -> getPackageDir ( ) ; if ( $ migrations = $ this -> getPackageOptionFile ( 'anime-db-migrations' ) ) { return $ dir . $ migrations ; } if ( file_exists ( $ dir . 'migrations.yml' ) ) { return $ dir . 'migrations.yml' ; } elseif ( file_exists ( $ dir . 'migrations.xml' ) ) { return $ dir . 'migrations.xml' ; } return ; }
Get path to migrations config file from package .
56,688
protected function parseConfig ( $ file ) { $ namespace = '' ; $ directory = '' ; $ config = file_get_contents ( $ file ) ; switch ( pathinfo ( $ file , PATHINFO_EXTENSION ) ) { case 'yml' : case 'yaml' : $ config = Yaml :: parse ( $ config ) ; if ( isset ( $ config [ 'migrations_namespace' ] ) ) { $ namespace = $ config [ 'migrations_namespace' ] ; } if ( isset ( $ config [ 'migrations_directory' ] ) ) { $ directory = $ config [ 'migrations_directory' ] ; } break ; case 'xml' : $ doc = new \ DOMDocument ( ) ; $ doc -> loadXML ( $ config ) ; $ list = $ doc -> getElementsByTagName ( 'migrations-namespace' ) ; if ( $ list -> length ) { $ namespace = $ list -> item ( 0 ) -> nodeValue ; } $ list = $ doc -> getElementsByTagName ( 'migrations-directory' ) ; if ( $ list -> length ) { $ directory = $ list -> item ( 0 ) -> nodeValue ; } break ; } return [ 'namespace' => $ namespace && $ namespace [ 0 ] == '\\' ? substr ( $ namespace , 1 ) : $ namespace , 'directory' => $ directory , ] ; }
Parse config file .
56,689
public function setMergeVars ( array $ vars ) { $ this -> merge_vars = array ( ) ; foreach ( $ vars as $ name => $ content ) { $ this -> addMergeVar ( $ name , $ content ) ; } return $ this ; }
Set all merge variables for this recipient . Will overwrite any currently set merge vars .
56,690
public function getResults ( $ url , $ locale = 'en_US' , $ strategy = 'desktop' , array $ extraParams = null ) { if ( 0 === preg_match ( '#http(s)?://.*#i' , $ url ) ) { throw new InvalidArgumentException ( 'Invalid URL' ) ; } $ client = new \ Guzzle \ Service \ Client ( $ this -> gateway ) ; $ request = $ client -> get ( 'runPagespeed' ) ; $ request -> getQuery ( ) -> set ( 'prettyprint' , false ) -> set ( 'url' , $ url ) -> set ( 'locale' , $ locale ) -> set ( 'strategy' , $ strategy ) ; if ( isset ( $ extraParams ) ) { $ query = $ request -> getQuery ( ) ; foreach ( $ extraParams as $ key => $ value ) { $ query [ $ key ] = $ value ; } } try { $ response = $ request -> send ( ) ; $ response = $ response -> getBody ( ) ; $ response = json_decode ( $ response , true ) ; return $ response ; } catch ( \ Guzzle \ Http \ Exception \ ClientErrorResponseException $ e ) { $ response = $ e -> getResponse ( ) ; $ response = $ response -> getBody ( ) ; $ response = json_decode ( $ response ) ; throw new RuntimeException ( $ response -> error -> message , $ response -> error -> code ) ; } }
Returns PageSpeed score page statistics and PageSpeed formatted results for specified URL
56,691
public function onAppDownloadedMergeComposerRequirements ( Downloaded $ event ) { $ old_config = file_get_contents ( $ this -> root_dir . 'composer.json' ) ; $ old_config = json_decode ( $ old_config , true ) ; $ new_config = file_get_contents ( $ event -> getPath ( ) . '/composer.json' ) ; $ new_config = json_decode ( $ new_config , true ) ; if ( $ old_config [ 'require' ] != $ new_config [ 'require' ] ) { $ new_config [ 'require' ] = array_merge ( $ old_config [ 'require' ] , $ new_config [ 'require' ] ) ; $ new_config = json_encode ( $ new_config , JSON_NUMERIC_CHECK | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) ; file_put_contents ( $ event -> getPath ( ) . '/composer.json' , $ new_config ) ; } }
Add requirements in composer . json from old version .
56,692
public function onAppDownloadedMergeConfigs ( Downloaded $ event ) { $ files = [ '/app/config/parameters.yml' , '/app/config/vendor_config.yml' , '/app/config/routing.yml' , '/app/bundles.php' , ] ; foreach ( $ files as $ file ) { if ( $ this -> fs -> exists ( $ this -> root_dir . $ file ) ) { $ this -> fs -> copy ( $ this -> root_dir . $ file , $ event -> getPath ( ) . $ file ) ; } } }
Copy configs from old version .
56,693
public function onAppDownloadedMergeBinRun ( Downloaded $ event ) { $ this -> fs -> remove ( [ $ this -> root_dir . 'bin/AnimeDB_Run.vbs' , $ this -> root_dir . 'bin/AnimeDB_Stop.vbs' , $ this -> root_dir . 'AnimeDB_Run.vbs' , $ this -> root_dir . 'AnimeDB_Stop.vbs' , ] ) ; if ( defined ( 'PHP_WINDOWS_VERSION_BUILD' ) ) { if ( ! $ this -> fs -> exists ( $ this -> root_dir . '/config.ini' ) ) { $ monitor = sys_get_temp_dir ( ) . '/' . basename ( $ this -> monitor ) ; if ( ! $ this -> fs -> exists ( $ monitor ) ) { $ this -> fs -> copy ( $ this -> monitor , $ monitor ) ; } if ( $ this -> zip -> open ( $ monitor ) !== true ) { throw new \ RuntimeException ( 'Failed unzip monitor' ) ; } $ this -> zip -> extractTo ( $ event -> getPath ( ) ) ; $ this -> zip -> close ( ) ; } $ old_file = $ this -> root_dir . '/config.ini' ; $ new_file = $ event -> getPath ( ) . '/config.ini' ; if ( $ this -> fs -> exists ( $ new_file ) && $ this -> fs -> exists ( $ old_file ) && is_readable ( $ new_file ) && md5_file ( $ old_file ) != md5_file ( $ new_file ) ) { $ old_body = file_get_contents ( $ old_file ) ; $ new_body = $ tmp_body = file_get_contents ( $ new_file ) ; $ new_body = $ this -> copyParam ( $ old_body , $ new_body , 'addr=%s' . PHP_EOL , self :: DEFAULT_ADDRESS ) ; $ new_body = $ this -> copyParam ( $ old_body , $ new_body , 'port=%s' . PHP_EOL , self :: DEFAULT_PORT ) ; $ new_body = $ this -> copyParam ( $ old_body , $ new_body , 'php=%s' . PHP_EOL , self :: DEFAULT_PHP ) ; if ( $ new_body != $ tmp_body ) { file_put_contents ( $ new_file , $ new_body ) ; } } } }
Merge bin AnimeDB_Run . vbs commands .
56,694
public function onAppDownloadedMergeBinService ( Downloaded $ event ) { $ old_file = $ this -> root_dir . 'AnimeDB' ; if ( ! $ this -> fs -> exists ( $ old_file ) ) { $ old_file = $ this -> root_dir . 'bin/service' ; } $ new_file = $ event -> getPath ( ) . '/AnimeDB' ; if ( is_readable ( $ new_file ) && md5_file ( $ old_file ) != md5_file ( $ new_file ) ) { $ old_body = file_get_contents ( $ old_file ) ; $ new_body = $ tmp_body = file_get_contents ( $ new_file ) ; $ new_body = $ this -> copyParam ( $ old_body , $ new_body , 'addr=\'%s\'' , self :: DEFAULT_ADDRESS ) ; $ new_body = $ this -> copyParam ( $ old_body , $ new_body , 'port=%s' . PHP_EOL , self :: DEFAULT_PORT ) ; $ new_body = $ this -> copyParam ( $ old_body , $ new_body , 'path=%s' . PHP_EOL , self :: DEFAULT_PATH ) ; if ( $ new_body != $ tmp_body ) { file_put_contents ( $ new_file , $ new_body ) ; } } }
Merge bin AnimeDB commands .
56,695
protected function copyParam ( $ from , $ target , $ param , $ default ) { if ( strpos ( $ from , sprintf ( $ param , $ default ) ) === false ) { list ( $ left , $ right ) = explode ( '%s' , $ param ) ; $ start = strpos ( $ from , $ left ) + strlen ( $ left ) ; $ end = strpos ( $ from , $ right , $ start ) ; $ value = substr ( $ from , $ start , $ end - $ start ) ; $ target = str_replace ( sprintf ( $ param , $ default ) , sprintf ( $ param , $ value ) , $ target ) ; } return $ target ; }
Copy param value if need .
56,696
public function onAppDownloadedChangeAccessToFiles ( Downloaded $ event ) { if ( ! defined ( 'PHP_WINDOWS_VERSION_BUILD' ) ) { $ this -> fs -> chmod ( [ $ event -> getPath ( ) . '/AnimeDB' , $ event -> getPath ( ) . '/app/console' , ] , 0755 ) ; } }
Change access to executable files .
56,697
public function add ( $ email , $ comment = NULL , $ subaccount = NULL ) { return $ this -> request ( 'add' , array ( 'email' => $ email , 'comment' => $ comment , 'subaccount' => $ subaccount ) ) ; }
Adds an email to your email rejection blacklist .
56,698
public function getList ( $ email = NULL , $ includeExpired = false , $ subaccount = NULL ) { return $ this -> listRejects ( $ email , $ includeExpired , $ subaccount ) ; }
Alias function of listRejects so that it s easier to migrate from the official mandrill PHP library .
56,699
public function listRejects ( $ email = NULL , $ includeExpired = false , $ subaccount = NULL ) { return $ this -> request ( 'list' , array ( 'email' => $ email , 'include_expired' => $ includeExpired , 'subaccount' => $ subaccount ) ) ; }
Retrieves your email rejection blacklist