idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
236,500
protected function attachPayloadErrorHandler ( ) { $ this -> getPayloadInstance ( ) ; if ( method_exists ( $ this -> instance , 'errorHandler' ) ) { $ this -> di -> get ( ErrorHandler :: class ) -> addHandler ( [ $ this -> instance , 'errorHandler' ] ) ; } }
Attach payload error handler
236,501
protected function launchWorker ( ) : bool { $ this -> log ( LogLevel :: DEBUG , "[{pid}] launching fleet worker" ) ; $ workerConfig = $ this -> payloadExec ( 'getWorkerConfig' ) ; if ( $ workerConfig === false ) { $ this -> log ( LogLevel :: DEBUG , "[{pid}] launch cancelled by payload" ) ; return false ; } $ thi...
Launch a fleet worker
236,502
protected function runPayloadApplication ( $ workerConfig = null ) : int { $ this -> getPayloadInstance ( ) ; try { $ runSuccess = $ this -> instance -> run ( $ workerConfig ) ; unset ( $ this -> instance ) ; } catch ( Exception $ ex ) { $ exitMessage = $ ex -> getMessage ( ) ; $ exitFile = $ ex -> getFile ( ) . ':' . ...
Run application worker
236,503
public function sendSignal ( int $ signal ) { $ runningPid = $ this -> lock -> getRunningPID ( ) ; if ( ! $ runningPid ) { return false ; } return posix_kill ( $ runningPid , $ signal ) ; }
Send a signal to the running daemon
236,504
public function workerSignal ( int $ signal ) { $ this -> log ( LogLevel :: DEBUG , "[{pid}] Caught signal '{$signal}' (SIGHUP) at worker - handing off to payload handler" ) ; switch ( $ signal ) { case SIGHUP : $ this -> payloadExec ( 'signal' , [ $ signal ] ) ; break ; case SIGUSR1 : $ this -> payloadExec ( 'signal' ...
Worker signal handler
236,505
protected function reapChild ( int $ pid , int $ status = null ) { if ( array_key_exists ( $ pid , $ this -> children ) ) { $ exited = pcntl_wexitstatus ( $ status ) ; if ( $ this -> exitMode == 'worst-case' ) { if ( abs ( $ exited ) > abs ( $ this -> exit ) ) { $ this -> exit = $ exited ; } } $ workerType = val ( $ pi...
Reap a fleet worker
236,506
public function reapZombies ( ) { $ reaped = 0 ; do { $ status = null ; $ pid = pcntl_wait ( $ status , WNOHANG ) ; if ( $ pid > 0 ) { $ this -> reapChild ( $ pid , $ status ) ; $ reaped ++ ; } } while ( $ pid > 0 ) ; return $ reaped ; }
Reap any available exited children
236,507
protected function reapAllChildren ( ) : bool { static $ killing = false ; if ( ! $ killing ) { $ this -> log ( LogLevel :: DEBUG , "[{pid}] Shutting down fleet operations..." ) ; $ killing = true ; foreach ( $ this -> children as $ childpid => $ childtype ) { posix_kill ( $ childpid , SIGKILL ) ; } pcntl_signal_dispat...
Force - reap all children and return
236,508
public static function time ( string $ time = 'now' , string $ format = null ) : \ DateTimeInterface { $ timezone = new \ DateTimeZone ( 'utc' ) ; if ( is_null ( $ format ) ) { $ date = new \ DateTime ( $ time , $ timezone ) ; } else { $ date = \ DateTime :: createFromFormat ( $ format , $ time , $ timezone ) ; } retur...
Get the time
236,509
public function levelPriority ( string $ level ) : int { static $ priorities = [ LogLevel :: DEBUG => LOG_DEBUG , LogLevel :: INFO => LOG_INFO , LogLevel :: NOTICE => LOG_NOTICE , LogLevel :: WARNING => LOG_WARNING , LogLevel :: ERROR => LOG_ERR , LogLevel :: CRITICAL => LOG_CRIT , LogLevel :: ALERT => LOG_ALERT , LogL...
Get the numeric priority for a log level .
236,510
protected function interpolateContext ( string $ format , array $ context = [ ] ) : string { $ final = preg_replace_callback ( '/{([^\s][^}]+[^\s]?)}/' , function ( $ matches ) use ( $ context ) { $ field = trim ( $ matches [ 1 ] , '{}' ) ; if ( array_key_exists ( $ field , $ context ) ) { return $ context [ $ field ] ...
Interpolate contexts into messages containing bracket - wrapped format strings .
236,511
public function setCategory ( ChildCategory $ v = null ) { if ( $ v === null ) { $ this -> setCategoryId ( NULL ) ; } else { $ this -> setCategoryId ( $ v -> getId ( ) ) ; } $ this -> aCategory = $ v ; if ( $ v !== null ) { $ v -> addC2M ( $ this ) ; } return $ this ; }
Declares an association between this object and a ChildCategory object .
236,512
public function getCategory ( ConnectionInterface $ con = null ) { if ( $ this -> aCategory === null && ( $ this -> category_id != 0 ) ) { $ this -> aCategory = ChildCategoryQuery :: create ( ) -> findPk ( $ this -> category_id , $ con ) ; } return $ this -> aCategory ; }
Get the associated ChildCategory object
236,513
public function createJob ( $ jobName , $ data = null , $ notBefore = null , $ reference = null ) { $ data = [ 'type' => $ jobName , 'data' => $ data , 'reference' => $ reference , ] ; if ( $ notBefore !== null ) { $ data [ 'notbefore' ] = new Time ( $ notBefore ) ; } $ queue = $ this -> newEntity ( $ data ) ; if ( $ q...
Add a new Job to the Queue .
236,514
public function requestJob ( ) { $ findCond = [ 'conditions' => [ 'completed' => 0 ] , 'order' => [ 'created ASC' , 'id ASC' , ] , 'limit' => 3 , ] ; $ jobs = $ this -> find ( 'all' , $ findCond ) -> all ( ) -> toArray ( ) ; for ( $ i = 0 ; $ i < count ( $ jobs ) ; $ i ++ ) { if ( $ jobs [ $ i ] [ 'stats' ] [ 'tries' ]...
Find a job to do .
236,515
public function markJobDone ( $ id ) { $ entity = $ this -> get ( $ id ) ; $ data = [ 'completed' => true , 'stats' => [ 'tries' => ( $ entity -> stats [ 'tries' ] + 1 ) , 'message' => $ entity -> stats [ 'message' ] . ( $ entity -> stats [ 'tries' ] + 1 ) . '. ' . 'Success!' . PHP_EOL ] ] ; $ this -> patchEntity ( $ e...
Mark job done and add some stats
236,516
public function markJobFailed ( $ id , $ message = null ) { $ entity = $ this -> get ( $ id ) ; $ data = [ 'completed' => false , 'stats' => [ 'tries' => ( $ entity -> stats [ 'tries' ] + 1 ) , 'message' => $ entity -> stats [ 'message' ] . ( $ entity -> stats [ 'tries' ] + 1 ) . '. ' . $ message . PHP_EOL ] ] ; $ this...
Job did not complete save a few stats so we can see what went wrong .
236,517
private function cleanBatches ( $ userId ) { $ where = EBatch :: A_USER_REF . '=' . ( int ) $ userId ; $ result = $ this -> daoBatch -> delete ( $ where ) ; return $ result ; }
Remove all existing batches for currently logged in admin user .
236,518
private function createBatch ( $ userId ) { $ entity = new EBatch ( ) ; $ entity -> setUserRef ( $ userId ) ; $ result = $ this -> daoBatch -> create ( $ entity ) ; return $ result ; }
Register new batch for currently logged in admin user .
236,519
public function quarterback ( $ createCommand ) { $ data = ( array ) $ createCommand ; $ data = $ this -> sanitize ( $ data , $ this -> type ) ; if ( $ this -> validate ( $ data , $ this -> type ) != "passed" ) { return $ this -> prepareResponseArray ( 'validation_failed' , 500 , $ data , $ this -> validate ( $ data , ...
The form processing steps .
236,520
public function processTasks ( ) { foreach ( $ this -> tasks as $ task ) { $ callable = new $ task ( ) ; $ result = call_user_func ( $ callable , $ this -> route , $ this -> console , $ this -> params ) ; if ( 1 === $ result ) { return false ; } } return true ; }
Process command tasks
236,521
public function build ( array $ taskConfigurations ) { $ resolver = new OptionsResolver ( ) ; $ tasks = [ ] ; foreach ( $ taskConfigurations as $ taskName => $ taskConfiguration ) { $ resolver -> clear ( ) ; if ( $ this -> debug === true ) { $ taskConfiguration [ 'debug' ] = $ this -> debug ; } if ( ! $ this -> hasCopy...
Build and return an array of Task .
236,522
public function removeByIds ( array $ in = [ ] , array $ notIn = [ ] ) { if ( ! count ( $ in ) && ! count ( $ notIn ) ) { return ; } $ qb = $ this -> createQueryBuilder ( 'e' ) ; if ( $ this -> getClassMetadata ( ) -> hasField ( 'deletedAt' ) ) { $ qb -> update ( ) -> set ( 'e.deletedAt' , ':date' ) -> setParameter ( '...
Will remove entities based on the ids you input .
236,523
public function typeroomAction ( Request $ request ) { $ roomType = new RoomType ( ) ; $ form = $ this -> createForm ( "room_types" , $ roomType ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ roomType ) ; $ em -> flush ...
Homepage for type room listing and editing types
236,524
public function login ( & $ subject , $ token ) { global $ logger ; global $ app ; try { if ( $ app -> getConfiguration ( ) -> isPreventMultipleLogins ( ) ) { list ( $ authInfo , $ roles , $ tokens , $ hashedSessionId ) = $ this -> authenticate ( $ token , true ) ; $ app -> getSessionManager ( ) -> getActiveSession ( )...
login Logs in the subject .
236,525
private function _generateCSRFToken ( $ length = 32 ) { $ randUtils = new RandomUtils ( ) ; $ randToken = $ randUtils -> getBytes ( $ length , true ) ; return base64_encode ( $ randToken ) ; }
Generate CSRF Token of given length .
236,526
private function _logAnalytics ( $ app , $ subject ) { if ( $ app -> getConfiguration ( ) -> logAnalytics ( ) == true ) { $ clientIP = ( isset ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) && ! empty ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) ) ? $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] : $ _SERVER [ 'REMOTE_ADDR' ] ; $ analytics...
Log Analytics using the route logger
236,527
public function createSubject ( $ context ) { global $ logger ; $ subject = $ this -> doCreateSubject ( $ context ) ; $ this -> _save ( $ subject ) ; return $ subject ; }
createSubject Creating the subject using the given context .
236,528
public function onUserActivationPost ( UserActivationEvent $ e ) { $ password = $ e -> getParam ( 'password' ) ; $ email = $ e -> getParam ( 'to' ) ; $ siteUrl = $ e -> getParam ( 'siteurl' ) ; $ loginUri = $ this -> getModuleOptions ( ) -> getLoginUri ( ) ; if ( null === $ email || null === $ password ) { return ; } $...
User Activation mail
236,529
public function setDefaultValue ( $ value ) { if ( ! is_array ( $ value ) ) { throw new \ InvalidArgumentException ( $ this -> getPath ( ) . ': the default value of an array node has to be an array.' ) ; } $ this -> defaultValue = $ value ; }
Sets the default value of this node .
236,530
public function setAddChildrenIfNoneSet ( $ children = array ( 'defaults' ) ) { if ( null === $ children ) { $ this -> defaultChildren = array ( 'defaults' ) ; } else { $ this -> defaultChildren = is_int ( $ children ) && $ children > 0 ? range ( 1 , $ children ) : ( array ) $ children ; } }
Adds default children when none are set .
236,531
public function prefix ( $ prefix = null ) { if ( null !== $ prefix ) { $ this -> prefix = substr ( md5 ( $ prefix ) , 0 , 10 ) . '_' ; } return $ this -> prefix ; }
Define prefix for Cache Application and return it .
236,532
public function destroy ( $ reopen = false ) { if ( $ this -> isOpen ) { $ params = session_get_cookie_params ( ) ; setcookie ( session_name ( ) , '' , time ( ) - 42000 , $ params [ 'path' ] , $ params [ 'domain' ] , $ params [ 'secure' ] , $ params [ 'httponly' ] ) ; session_destroy ( ) ; $ this -> isOpen = false ; } ...
Destroys the current session and its data .
236,533
public function open ( $ data = null ) { if ( ! session_start ( ) ) { throw new \ RuntimeException ( 'Could not open session.' ) ; } session_regenerate_id ( true ) ; $ this -> isOpen = true ; if ( $ data === null ) { if ( $ this -> data === null ) { $ data = & $ _SESSION ; } else { $ this -> flashStorage -> decrement (...
Starts the session . Regenerates the session ID each request for security reasons and updates flash variables .
236,534
public function sessionName ( $ name = null ) { if ( $ name === null ) { return session_name ( ) ; } if ( $ this -> isOpen ) { throw new \ InvalidArgumentException ( 'The session has already been opened.' ) ; } if ( ! is_string ( $ name ) ) { throw new \ InvalidArgumentException ( 'Session name must be null or a string...
Sets or gets the session name .
236,535
public function savePath ( $ path = null ) { if ( $ path === null ) { return session_save_path ( ) ; } if ( $ this -> isOpen ) { throw new \ InvalidArgumentException ( 'The session has already been opened.' ) ; } if ( ! is_string ( $ path ) ) { throw new \ InvalidArgumentException ( 'Session path must be null or a stri...
Sets or gets the current session save path .
236,536
public function trigger ( $ eventName , $ arg1 = 'NULLPARAMETER' ) { $ this -> Logger -> debug ( 'Triggering event [' . $ eventName . ']' ) ; if ( ( $ event = $ this -> ApplicationContext -> getEvent ( $ eventName ) ) == false ) return ; $ args = array ( ) ; $ stack = null ; if ( $ arg1 !== 'NULLPARAMETER' ) { if ( PHP...
Trigger the event passing parameters to callbacks
236,537
public function createFolder ( $ folder , $ allFolders = FALSE ) { if ( substr ( $ folder , - 1 ) != '/' ) $ folder = $ folder . '/' ; if ( ! is_dir ( $ folder ) ) { @ mkdir ( $ folder , 0777 , $ allFolders ) or die ( "Error creating folder '{$folder}'." ) ; } }
To create a new folder
236,538
public function moveFile ( $ file , $ originalFolder , $ newFolder ) { if ( substr ( $ originalFolder , - 1 ) != '/' ) $ originalFolder = $ originalFolder . '/' ; if ( substr ( $ newFolder , - 1 ) != '/' ) $ newFolder = $ newFolder . '/' ; $ this -> copyFile ( $ originalFolder . $ file , $ newFolder . $ file ) ; $ this...
To move a file
236,539
public function copyFile ( $ originalFile , $ newFile ) { if ( is_file ( $ originalFile ) ) { @ copy ( $ originalFile , $ newFile ) or die ( "File '{$originalFile}' can't be copied to '{$newFile}'." ) ; } else { die ( "File '{$originalFile}' doesn't exist." ) ; } }
To copy a file
236,540
public function readFolder ( $ folder , $ sort = 0 ) { if ( substr ( $ folder , - 1 ) != '/' ) $ folder = $ folder . '/' ; $ this -> data = @ scandir ( $ folder , $ sort ) or die ( "Error reading folder: '{$folder}'." ) ; $ this -> numberOfFiles = count ( $ this -> data ) ; }
Reading the files and folders of a certain folder
236,541
public function processUploadedFile ( $ originalFile , $ newFile , $ folder ) { if ( substr ( $ folder , - 1 ) != '/' ) $ folder = $ folder . '/' ; @ move_uploaded_file ( $ originalFile , $ folder . $ newFile ) or die ( "File: '{$originalFile}' couldn't be moved '{$folder}'." ) ; @ chmod ( $ folder . $ newFile , 0777 )...
Process an uploaded file and moved to a folder on the server
236,542
public function findOrNew ( $ id , $ columns = [ '*' ] ) { if ( is_null ( $ instance = $ this -> find ( $ id , $ columns ) ) ) { $ instance = $ this -> related -> newInstance ( ) ; $ instance -> setAttribute ( $ this -> getPlainForeignKey ( ) , $ this -> getParentKey ( ) ) ; } return $ instance ; }
Find a model by its primary key or return new instance of the related model .
236,543
public function tokenize ( $ callback = null ) { $ this -> reset ( ) ; if ( ! is_callable ( $ callback ) ) { $ callback = function ( ) { } ; } for ( $ line = 1 , $ i = 0 ; $ i < $ this -> strlen ; $ i ++ ) { if ( mb_substr ( $ this -> source , $ i , 1 ) === "\n" ) { $ line ++ ; } switch ( true ) { case mb_substr ( $ th...
Main rendering function that passes tokens to the supplied callback .
236,544
protected function addNode ( int $ start , string $ type , int $ line , int $ offset1 , int $ offset2 , $ callback ) { $ this -> flushText ( $ start , $ callback ) ; switch ( $ type ) { case self :: TYPE_VARIABLE_ESCAPE : $ end = $ this -> findVariable ( $ start , true ) ; break ; case self :: TYPE_VARIABLE_UNESCAPE : ...
Forms the node and passes to the callback
236,545
protected function findVariable ( int $ i , bool $ escape ) : int { $ close = ( $ escape === true ? '}}}' : '}}' ) ; for ( ; mb_substr ( $ this -> source , $ i , mb_strlen ( $ close ) ) !== $ close ; $ i ++ ) { } return $ i + mb_strlen ( $ close ) ; }
Since we know where the start is we need to find the end in the source .
236,546
protected function save ( $ origin , $ short = null ) { $ shortener = Shortener :: updateOrCreate ( [ 'hash' => hash ( 'sha512' , $ origin ) ] , [ 'url' => $ origin , 'short' => $ short ] ) ; return $ shortener -> exists ? $ shortener -> getKey ( ) : false ; }
Save record to database .
236,547
public function addColumnName ( $ columnName ) { if ( ! is_string ( $ columnName ) || ( strlen ( $ columnName ) <= 0 ) ) { throw SchemaException :: invalidIndexColumnName ( $ this -> getName ( ) ) ; } $ this -> columnNames [ ] = $ columnName ; }
Adds a column name to the index .
236,548
public function setUnique ( $ unique ) { if ( ! is_bool ( $ unique ) ) { throw SchemaException :: invalidIndexUniqueFlag ( $ this -> getName ( ) ) ; } $ this -> unique = $ unique ; }
Sets the unique index flag .
236,549
public function isBetterThan ( Index $ index ) { if ( $ this -> hasSameColumnNames ( $ index -> getColumnNames ( ) ) && $ this -> isUnique ( ) && ! $ index -> isUnique ( ) ) { return true ; } return false ; }
Checks if the index is better than the given index . Better means the index can replace the given .
236,550
private function createUser ( $ sendEmail = true ) { $ model = new RegisterForm ; if ( ! empty ( $ _POST ) ) { $ model -> attributes = $ _POST ; if ( $ model -> save ( $ sendEmail ) ) return Users :: model ( ) -> findByAttributes ( array ( 'email' => $ _POST [ 'email' ] ) ) -> getAPIAttributes ( array ( 'password' ) , ...
Utilizes the registration form to create a new user
236,551
public function handle ( $ errorLevel , $ message , $ file , $ line , $ context ) { if ( $ this -> errorLevel === 0 ) { return FALSE ; } if ( $ this -> displayErrors && error_reporting ( ) & $ errorLevel && $ this -> errorLevel & $ errorLevel ) { throw new \ ErrorException ( sprintf ( '%s: %s in %s line %d' , isset ( $...
handle error and throw exception when error level limits are met
236,552
public function setTemplatePath ( $ path , \ Twig_Environment $ twig = null , $ extensions = [ ] ) { $ this -> paths [ 'templates' ] = $ path ; if ( is_null ( $ twig ) === true ) { $ loader = new \ Twig_Loader_Filesystem ( $ path ) ; $ twig = new \ Twig_Environment ( $ loader ) ; } $ twig -> setExtensions ( $ extension...
Sets the templates path .
236,553
public function run ( $ console = false ) { $ instance = $ this -> console ( ) ; return $ console ? $ instance : $ instance -> run ( ) ; }
Runs the current console .
236,554
protected function console ( ) { $ files = glob ( $ this -> getCommandPath ( ) . '/*.php' ) ; $ path = strlen ( $ this -> getCommandPath ( ) . DIRECTORY_SEPARATOR ) ; $ pattern = '/\\.[^.\\s]{3,4}$/' ; foreach ( ( array ) $ files as $ file ) { $ class = preg_replace ( $ pattern , '' , substr ( $ file , $ path ) ) ; $ c...
Sets up Twig and gets all commands from the specified path .
236,555
public function createMap ( ... $ paths ) { $ classes = [ ] ; $ this -> finder -> files ( ) -> ignoreUnreadableDirs ( ) -> in ( $ paths ) ; foreach ( $ this -> excludePathPatterns as $ exclude ) { $ this -> finder -> notPath ( $ exclude ) ; } foreach ( $ this -> inPathPatterns as $ inPath ) { $ this -> finder -> path (...
Create a map for a given path
236,556
public function compare ( Column $ oldColumn , Column $ newColumn ) { $ differences = array ( ) ; if ( $ oldColumn -> getType ( ) !== $ newColumn -> getType ( ) ) { $ differences [ ] = 'type' ; } if ( $ oldColumn -> getLength ( ) !== $ newColumn -> getLength ( ) ) { $ differences [ ] = 'length' ; } if ( $ oldColumn -> ...
Compares two columns .
236,557
public function scopePublishedAt ( Builder $ query , $ year ) { return $ this -> scopePublished ( $ query ) -> where ( DB :: raw ( 'YEAR(published_at)' ) , $ year ) ; }
Scope only published posts .
236,558
protected static function extractSeoAttributes ( array $ inputs ) { return [ 'title' => Arr :: get ( $ inputs , 'seo_title' ) , 'description' => Arr :: get ( $ inputs , 'seo_description' ) , 'keywords' => Arr :: get ( $ inputs , 'seo_keywords' ) , 'metas' => Arr :: get ( $ inputs , 'seo_metas' , [ ] ) , ] ; }
Extract the seo attributes .
236,559
public static function identify_service ( $ url ) { if ( preg_match ( '%youtube|youtu\.be%i' , $ url ) ) { return self :: YOUTUBE ; } elseif ( preg_match ( '%vimeo%i' , $ url ) ) { return self :: VIMEO ; } elseif ( preg_match ( '%23video%' , $ url ) ) { return self :: TWENTYTHREE ; } return null ; }
Determines which cloud video provider is being used based on the passed url .
236,560
public static function get_url_id ( $ url ) { $ service = self :: identify_service ( $ url ) ; if ( $ service == self :: YOUTUBE ) { return self :: get_youtube_id ( $ url ) ; } elseif ( $ service == self :: VIMEO ) { return self :: get_vimeo_id ( $ url ) ; } elseif ( $ service == self :: TWENTYTHREE ) { return self :: ...
Determines which cloud video provider is being used based on the passed url and extracts the video id from the url .
236,561
public static function get_url_embed ( $ url ) { $ service = self :: identify_service ( $ url ) ; $ id = self :: get_url_id ( $ url ) ; if ( $ service == self :: YOUTUBE ) { return self :: get_youtube_embed ( $ id ) ; } elseif ( $ service == self :: VIMEO ) { return self :: get_vimeo_embed ( $ id ) ; } elseif ( $ servi...
Determines which cloud video provider is being used based on the passed url extracts the video id from the url and builds an embed url .
236,562
public static function get_youtube_id ( $ input ) { if ( preg_match ( '#/embed/([^\?&"]+)#' , $ input , $ matches ) ) { return $ matches [ 1 ] ; } if ( preg_match ( '#vi?=([^&]+)#' , $ input , $ matches ) ) { return $ matches [ 1 ] ; } if ( preg_match ( '#//youtu.be/([^\?&"/]+)#' , $ input , $ matches ) ) { return $ ma...
Parses various youtube urls and returns video identifier .
236,563
public static function get_vimeo_id ( $ input ) { if ( preg_match ( '#/vimeo.com/(\d+)#' , $ input , $ matches ) ) { return $ matches [ 1 ] ; } if ( preg_match ( '#/video/(\d+)#' , $ input , $ matches ) ) { return $ matches [ 1 ] ; } return null ; }
Parses various vimeo urls and returns video identifier .
236,564
public function findAllWithAspect ( $ aspectName , $ restrictSiteSlug = null ) { $ dto = new DTO ( ) ; $ dto -> setParameter ( "IncludesAspect" , ltrim ( $ aspectName , '@' ) ) ; if ( ! is_null ( $ restrictSiteSlug ) ) $ dto -> setParameter ( "AnchoredSiteSlug" , $ restrictSiteSlug ) ; $ dto = $ this -> findAll ( $ dto...
Returns all elements that have the specified aspect
236,565
public function findAllFromString ( $ aspectsOrElements ) { $ results = array ( ) ; foreach ( explode ( ',' , $ aspectsOrElements ) as $ aspectOrElement ) { $ aspectOrElement = trim ( $ aspectOrElement ) ; if ( substr ( $ aspectOrElement , 0 , 1 ) == '@' ) { $ els = $ this -> findAllWithAspect ( $ aspectOrElement ) ; f...
Returns all elements for given aspect names and element slugs
236,566
public function read ( $ byteCount , $ allowIncomplete = false ) { $ maxByteCount = $ this -> getRemainingByteCount ( ) ; if ( ! $ allowIncomplete && $ maxByteCount < $ byteCount ) { throw new Exception \ UnderflowException ( 'The source doesn\'t have enough remaining data to fulfill the request' ) ; } $ byteCount = ma...
Reads and consumes data from the source .
236,567
static public function set ( $ key , $ value ) { $ config = & self :: $ _config ; Utils :: arraySet ( $ config , $ key , $ value ) ; }
Add or set configuration key
236,568
private function AddTitleField ( ) { $ name = 'Title' ; $ this -> AddField ( Input :: Text ( $ name , $ this -> page -> GetTitle ( ) ) ) ; }
Adds the title field to the form
236,569
private function AddDescriptionField ( ) { $ name = 'Description' ; $ this -> AddField ( Input :: Text ( $ name , $ this -> page -> GetDescription ( ) ) ) ; }
Adds the description field to the form
236,570
private function AddKeywordsField ( ) { $ name = 'Keywords' ; $ this -> AddField ( Input :: Text ( $ name , $ this -> page -> GetKeywords ( ) ) ) ; }
Adds the keywords field to the form
236,571
private function AddLayoutField ( ) { $ name = 'Layout' ; $ select = new Select ( $ name ) ; if ( $ this -> page -> Exists ( ) ) { $ select -> SetValue ( $ this -> page -> GetLayout ( ) -> GetID ( ) ) ; } $ select -> AddOption ( '' , Trans ( 'Core.PleaseSelect' ) ) ; $ sql = Access :: SqlBuilder ( ) ; $ tbl = Layout ::...
Adds the layout field to the form
236,572
private function AddMenuAccessField ( ) { $ name = 'MenuAccess' ; $ value = $ this -> page -> Exists ( ) ? $ this -> page -> GetMenuAccess ( ) : ( string ) MenuAccess :: Authorized ( ) ; $ select = new Select ( $ name , $ value ) ; foreach ( MenuAccess :: AllowedValues ( ) as $ access ) { $ select -> AddOption ( $ acce...
Adds the menu access select
236,573
private function AddPublishToHourField ( ) { $ name = 'PublishToHour' ; $ to = $ this -> page -> GetPublishTo ( ) ; $ field = Input :: Text ( $ name , $ to ? $ to -> ToString ( 'H' ) : '' ) ; $ field -> SetHtmlAttribute ( 'data-type' , 'hour' ) ; $ this -> AddField ( $ field ) ; }
Adds the publish to hour field
236,574
private function AddSitemapRelevanceField ( ) { $ name = 'SitemapRelevance' ; $ value = $ this -> page -> Exists ( ) ? 10 * $ this -> page -> GetSitemapRelevance ( ) : 7 ; $ field = new Select ( $ name , $ value ) ; for ( $ val = 0 ; $ val <= 10 ; ++ $ val ) { $ decSep = Trans ( 'Core.DecimalSeparator' ) ; $ thousSep =...
Adds the sitemap relevance field
236,575
private function AddSitemapChangeFrequencyField ( ) { $ name = 'SitemapChangeFrequency' ; $ value = $ this -> page -> Exists ( ) ? $ this -> page -> GetSitemapChangeFrequency ( ) : ( string ) ChangeFrequency :: Weekly ( ) ; $ field = new Select ( $ name , $ value ) ; $ values = ChangeFrequency :: AllowedValues ( ) ; fo...
Adds the sitemap change frequency field
236,576
protected function OnSuccess ( ) { $ prevLayout = $ this -> page -> GetLayout ( ) ; $ this -> page -> SetName ( $ this -> Value ( 'Name' ) ) ; $ this -> page -> SetUrl ( $ this -> Value ( 'Url' ) ) ; $ this -> page -> SetSite ( $ this -> site ) ; $ this -> page -> SetTitle ( $ this -> Value ( 'Title' ) ) ; $ this -> pa...
Saves the page
236,577
private function ReassignContents ( Layout $ prevLayout , Layout $ newLayout ) { if ( $ prevLayout -> Equals ( $ newLayout ) ) { return ; } $ oldAreas = Area :: Schema ( ) -> FetchByLayout ( false , $ prevLayout ) ; foreach ( $ oldAreas as $ oldArea ) { $ newArea = $ this -> FindNewArea ( $ oldArea , $ newLayout ) ; if...
Reassigns contents by area names if layout was changed
236,578
private function SaveRights ( ) { $ groupID = $ this -> Value ( 'UserGroup' ) ; $ userGroup = Usergroup :: Schema ( ) -> ByID ( $ groupID ) ; $ this -> page -> SetUserGroup ( $ userGroup ) ; if ( ! $ userGroup ) { $ oldRights = $ this -> page -> GetUserGroupRights ( ) ; if ( $ oldRights ) { $ oldRights -> GetContentRig...
Saves the group and right settings
236,579
private function SaveMemberGroups ( ) { $ selectedIDs = Request :: PostArray ( 'MemberGroup' ) ; if ( $ this -> page -> GetGuestsOnly ( ) ) { $ selectedIDs = array ( ) ; } $ exIDs = Membergroup :: GetKeyList ( MembergroupUtil :: PageMembergroups ( $ this -> page ) ) ; $ this -> DeleteOldMemberGroups ( $ selectedIDs ) ;...
Saves the member groups
236,580
private function DeleteOldMemberGroups ( array $ selectedIDs ) { $ sql = Access :: SqlBuilder ( ) ; $ tblPgGrp = PageMembergroup :: Schema ( ) -> Table ( ) ; $ where = $ sql -> Equals ( $ tblPgGrp -> Field ( 'Page' ) , $ sql -> Value ( $ this -> page -> GetID ( ) ) ) ; if ( count ( $ selectedIDs ) ) { $ inSelected = $ ...
Deletes the old member groups
236,581
private function SaveNewMemberGroups ( array $ selectedIDs , array $ exIDs ) { foreach ( $ selectedIDs as $ selID ) { if ( ! in_array ( $ selID , $ exIDs ) ) { $ pgGrp = new PageMembergroup ( ) ; $ pgGrp -> SetPage ( $ this -> page ) ; $ pgGrp -> SetMemberGroup ( new Membergroup ( $ selID ) ) ; $ pgGrp -> Save ( ) ; } ...
Saves page member groups not already assigned
236,582
private function SaveNew ( ) { $ treeBuilder = new TreeBuilder ( new PageTreeProvider ( $ this -> site ) ) ; $ treeBuilder -> Insert ( $ this -> page , $ this -> parent , $ this -> previous ) ; }
Takes care of page tree insertion important for a fresh page
236,583
private function AdjustHtaccess ( ) { $ file = Path :: Combine ( PHINE_PATH , 'Public/.htaccess' ) ; if ( ! File :: Exists ( $ file ) ) { throw new \ Exception ( 'HTACCESS FILE $file NOT FOUND' ) ; } $ writer = new Writer ( ) ; $ rewriter = new Rewriter ( $ writer ) ; $ text = File :: GetContents ( $ file ) ; $ startPo...
Adds necessary rewrite commands
236,584
public function get ( $ idOrDocument ) { $ modelFetcher = $ this -> getServiceLocator ( ) -> get ( 'document.model.fetcher' ) ; $ this -> getEventManager ( ) -> trigger ( __FUNCTION__ , $ this , array ( 'document' => $ idOrDocument ) ) ; $ classifiedModel = $ modelFetcher -> get ( $ idOrDocument ) ; $ this -> getEventM...
Get a classified model
236,585
public function expired ( $ limit = 10 ) { $ main = $ this -> getServiceLocator ( ) -> get ( 'neobazaar.service.main' ) ; $ em = $ main -> getEntityManager ( ) ; $ cache = $ this -> getServiceLocator ( ) -> get ( 'ClassifiedCache' ) ; $ documentRepository = $ main -> getDocumentEntityRepository ( ) ; $ documents = $ do...
This service will trigger event with expired classifieds . anything binded with these events will run
236,586
public function activationEmailResend ( $ limit = 10 ) { $ main = $ this -> getServiceLocator ( ) -> get ( 'neobazaar.service.main' ) ; $ em = $ main -> getEntityManager ( ) ; $ cache = $ this -> getServiceLocator ( ) -> get ( 'ClassifiedCache' ) ; $ documentRepository = $ main -> getDocumentEntityRepository ( ) ; $ do...
This service will trigger event with classifieds that needs activetion email to be resent .
236,587
public static function indent ( $ lines , $ cnt = 1 ) { $ new = [ ] ; $ lines = str_contains ( $ lines , '\r\n' ) ? explode ( "\r\n" , $ lines ) : explode ( "\n" , $ lines ) ; foreach ( $ lines as $ line ) $ new [ ] = str_repeat ( "\t" , $ cnt ) . $ line ; return implode ( "\n" , $ new ) ; }
Indents each line
236,588
public static function prependLines ( $ lines , $ prepend , $ prependFirstLine = false ) { $ new = [ ] ; $ lines = str_contains ( $ lines , '\r\n' ) ? explode ( "\r\n" , $ lines ) : explode ( "\n" , $ lines ) ; if ( ! $ prependFirstLine ) $ new [ ] = $ lines [ 0 ] ; for ( $ i = $ prependFirstLine ? 0 : 1 ; $ i < count ...
Prepends each line
236,589
public static function getCode ( $ val , $ alpha3 = false ) { if ( self :: $ _countryFlip === array ( ) ) { self :: $ _countryFlip = array_flip ( self :: $ _countries ) ; } if ( ! array_key_exists ( $ val , self :: $ _countryFlip ) ) { return null ; } $ result = self :: $ _countryFlip [ $ val ] ; if ( $ alpha3 ) { retu...
Converts a KlarnaCountry constant to the respective country code .
236,590
public static function checkLanguage ( $ country , $ language ) { switch ( $ country ) { case KlarnaCountry :: AT : case KlarnaCountry :: DE : return ( $ language === KlarnaLanguage :: DE ) ; case KlarnaCountry :: NL : return ( $ language === KlarnaLanguage :: NL ) ; case KlarnaCountry :: FI : return ( $ language === K...
Checks country against currency and returns true if they match .
236,591
public static function checkCurrency ( $ country , $ currency ) { switch ( $ country ) { case KlarnaCountry :: AT : case KlarnaCountry :: DE : case KlarnaCountry :: NL : case KlarnaCountry :: FI : return ( $ currency === KlarnaCurrency :: EUR ) ; case KlarnaCountry :: DK : return ( $ currency === KlarnaCurrency :: DKK ...
Checks country against language and returns true if they match .
236,592
public static function getLanguage ( $ country ) { switch ( $ country ) { case KlarnaCountry :: AT : case KlarnaCountry :: DE : return KlarnaLanguage :: DE ; case KlarnaCountry :: NL : return KlarnaLanguage :: NL ; case KlarnaCountry :: FI : return KlarnaLanguage :: FI ; case KlarnaCountry :: DK : return KlarnaLanguage...
Get language for supplied country . Defaults to English .
236,593
public function isStringType ( ) { $ stringTypeList = [ 'char' , 'varchar' , 'tinyblob' , 'blob' , 'mediumblob' , 'longblob' , 'tinytext' , 'text' , 'mediumtext' , 'longtext' ] ; $ isString = false ; $ type = trim ( strtolower ( $ this -> getType ( ) ) ) ; foreach ( $ stringTypeList as $ stringType ) { if ( substr ( $ ...
Returns true if the column is a string type .
236,594
protected function _createInvalidArgumentException ( $ message = null , $ code = null , RootException $ previous = null , $ argument = null ) { return new InvalidArgumentException ( $ message , $ code , $ previous , $ argument ) ; }
Creates a new Dhii invalid argument exception .
236,595
private function createPage ( $ page , $ options , $ models ) { $ request = $ this -> getRequest ( ) ; if ( $ request -> getMethod ( ) == 'POST' ) { $ data = $ request -> get ( 'page' ) ; $ page -> setModel ( $ data [ 'model' ] ) ; } $ formClassName = isset ( $ models [ $ page -> getModel ( ) ] [ 'back' ] [ 'form' ] ) ...
Create form for page entity use for edit or add page
236,596
public function removeAction ( $ pageId ) { $ page = $ this -> getPage ( $ pageId ) ; if ( $ page -> getSlug ( ) == '' ) { throw new AccessDeniedException ( ) ; } $ request = $ this -> getRequest ( ) ; if ( $ request -> request -> get ( 'confirm' ) === 'yes' ) { if ( $ this -> container -> getParameter ( 'fulgurio_ligh...
Remove page with confirm form
236,597
public function copyAction ( $ sourceId , $ targetId , $ lang ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ source = $ this -> getPage ( $ sourceId ) ; $ target = $ this -> getPage ( $ targetId ) ; $ newPage = clone ( $ source ) ; $ newPage -> setParent ( $ target ) ; if ( $ target -> getLang ( ) ) { $ new...
Page copy use for multilang site
236,598
public function changePositionAction ( ) { $ request = $ this -> getRequest ( ) ; if ( $ request -> isXmlHttpRequest ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ pageRepository = $ this -> getDoctrine ( ) -> getRepository ( 'FulgurioLightCMSBundle:Page' ) ; $ page = $ this -> getPage ( $ request -> re...
Change page position using ajax tree
236,599
private function getPageMetas ( $ pageId ) { $ pageMetas = array ( ) ; $ metas = $ this -> getDoctrine ( ) -> getRepository ( 'FulgurioLightCMSBundle:PageMeta' ) -> findByPage ( $ pageId ) ; foreach ( $ metas as $ meta ) { $ pageMetas [ $ meta -> getMetaKey ( ) ] = $ meta ; } return $ pageMetas ; }
Get meta data from given ID page