idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
237,500
public function createNorthstarUser ( $ user ) { $ northstarAPIConfig = $ this -> mbConfig -> getProperty ( 'northstar_config' ) ; if ( empty ( $ northstarAPIConfig [ 'host' ] ) ) { throw new Exception ( 'MB_Toolbox->createNorthstarUser() northstar_config missing host setting.' ) ; } $ requiredSet = false ; if ( ! empt...
Create a user entry in Northstar the DoSomething User API .
237,501
public function lookupNorthstarUser ( $ user ) { $ northstarAPIConfig = $ this -> mbConfig -> getProperty ( 'northstar_config' ) ; if ( empty ( $ northstarAPIConfig [ 'host' ] ) ) { throw new Exception ( 'MB_Toolbox->lookupNorthstarUser() northstar_config missing host setting.' ) ; } $ northstarUrl = $ northstarAPIConf...
Lookup user on Northstar .
237,502
public function parseNorthstarUserResponse ( $ response ) { if ( ! is_array ( $ response ) || empty ( $ response [ 0 ] ) || empty ( $ response [ 1 ] ) ) { throw new Exception ( '- Unexpected Northstar response:' . var_export ( $ response , true ) ) ; } list ( $ user , $ httpCode ) = $ response ; if ( $ httpCode === 201...
Parse Northstar user response throw exception on failure .
237,503
public function cmdGetUser ( ) { $ result = $ this -> getListUser ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableUser ( $ result ) ; $ this -> output ( ) ; }
Callback for user - get command
237,504
public function cmdUpdateUser ( ) { $ params = $ this -> getParam ( ) ; if ( empty ( $ params [ 0 ] ) || count ( $ params ) < 2 ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( ! is_numeric ( $ params [ 0 ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ this -> ...
Callback for user - update command
237,505
protected function submitAddUser ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> setSubmittedJson ( 'data' ) ; $ this -> validateComponent ( 'user' ) ; $ this -> addUser ( ) ; }
Add a new user at once
237,506
protected function addUser ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> user -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } }
Add a new user
237,507
protected function wizardAddUser ( ) { $ this -> validatePrompt ( 'email' , $ this -> text ( 'E-mail' ) , 'user' ) ; $ this -> validatePrompt ( 'password' , $ this -> text ( 'Password' ) , 'user' ) ; $ this -> validatePrompt ( 'name' , $ this -> text ( 'Name' ) , 'user' ) ; $ this -> validatePrompt ( 'role_id' , $ this...
Add a new user step by step
237,508
public function setStatusUser ( $ status ) { $ options = $ id = $ result = null ; if ( $ this -> getParam ( 'all' ) ) { $ options = array ( ) ; } else { $ id = $ this -> getParam ( 0 ) ; if ( ! is_numeric ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } if ( $ this -> getParam ( 'role' ...
Sets a user status
237,509
public function setQueueId ( $ id ) { if ( $ id === null ) { $ this -> queueId = null ; return $ this ; } if ( ! is_string ( $ id ) ) { throw new InvalidArgumentException ( 'Queue ID must be a string' ) ; } $ this -> queueId = $ id ; return $ this ; }
Set the queue s ID .
237,510
public function initialize ( ) { $ request = $ this -> router -> getAction ( ) ; $ isRouteCallback = $ this -> processRequestParameters ( $ request ) ; $ this -> start ( $ isRouteCallback ) ; return $ this ; }
Calls the proper shell for app execution
237,511
protected function processNode ( $ node ) { if ( $ node instanceof DOMDocumentType ) { return '' ; } if ( $ node instanceof DOMText ) { return preg_replace ( "/\\s+/im" , " " , $ node -> wholeText ) ; } $ tag = strtolower ( $ node -> nodeName ) ; if ( in_array ( $ tag , $ this -> ignoredBlockTags ) ) { return '' ; } $ ...
Recursively called method that creates the plain text required for a give tag .
237,512
protected function lastTagName ( $ node ) { $ lastNode = $ node -> previousSibling ; while ( $ lastNode != null ) { if ( $ lastNode instanceof DOMElement ) { break ; } $ lastNode = $ lastNode -> previousSibling ; } $ lastTag = '' ; if ( $ lastNode instanceof DOMElement && $ lastNode != null ) { $ lastTag = strtolower (...
Find the previous sibling tag name for this node
237,513
protected function nextTagName ( $ node ) { $ nextNode = $ node -> nextSibling ; while ( $ nextNode != null ) { if ( $ nextNode instanceof DOMElement ) { break ; } $ nextNode = $ nextNode -> nextSibling ; } $ nextTag = '' ; if ( $ nextNode instanceof DOMElement && $ nextNode != null ) { $ nextTag = strtolower ( $ nextN...
Find the next sibling tag name for this node
237,514
public function getToken ( $ tokenId ) { $ sessionToken = $ this -> sessionDataBag -> get ( $ this -> namespace . '/' . $ tokenId ) ; if ( ! $ sessionToken ) { throw new CsrfTokenException ( sprintf ( "CSRF token with id '%s' not found." , $ tokenId ) ) ; } return $ sessionToken ; }
retrieves token stored in session under namespaced token id
237,515
public function setToken ( $ tokenId , CsrfToken $ token ) { if ( ! trim ( ( string ) $ tokenId ) ) { throw new \ InvalidArgumentException ( 'Invalid token id.' ) ; } $ this -> sessionDataBag -> set ( $ this -> namespace . '/' . $ tokenId , $ token ) ; }
store token under namespaced token id in session
237,516
public function register ( callable $ callback , $ priority = null ) { $ priority = $ this -> getPriority ( $ priority ) ; if ( ! isset ( $ this -> callbacks [ $ priority ] ) ) { $ this -> callbacks [ $ priority ] = [ ] ; } $ this -> callbacks [ $ priority ] [ ] = $ callback ; $ this -> lowestPriority = max ( $ priorit...
Registers a callback to be called on shutdown .
237,517
public function addProcessor ( Processor $ processor , int $ precedence = ProcessChain :: RUN_DEFAULT ) { return $ this -> appendProcessor ( $ processor , static :: STAGE_PROCESS , $ precedence ) ; }
Add a processor to the chain in the PROCESS stage . Any operator in this stage is expected to produce a response .
237,518
public function addPostProcessor ( Processor $ processor , int $ precedence = ProcessChain :: RUN_DEFAULT ) { return $ this -> appendProcessor ( $ processor , static :: STAGE_POSTPROCESS , $ precedence ) ; }
Adds a post processor to the pipeline . A postprocessor is a filter that operates on the response rather than producing it .
237,519
protected function appendProcessor ( Processor $ processor , int $ stage , int $ precedence = ProcessChain :: RUN_DEFAULT ) { $ stage = WF :: clamp ( $ stage , static :: STAGE_FILTER , static :: STAGE_POSTPROCESS ) ; $ precedence = WF :: clamp ( $ precedence , static :: RUN_FIRST , static :: RUN_LAST ) ; $ this -> proc...
Helper to add a processor to the pipeline
237,520
public function getProcessors ( int $ stage ) { $ list = [ ] ; foreach ( $ this -> processors as $ proc ) { if ( $ proc [ 'stage' ] === $ stage ) $ list [ ] = $ proc [ 'processor' ] ; } return $ list ; }
Get a list of processor for a stage
237,521
public function process ( Request $ request ) { $ result = new Result ; $ stage = static :: STAGE_FILTER ; foreach ( $ this -> processors as $ processor ) { if ( $ processor [ 'stage' ] < $ stage ) continue ; $ stage = $ processor [ 'stage' ] ; $ processor = $ processor [ 'processor' ] ; try { $ processor -> process ( ...
Process a request - put it through the pipeline and return the response . The request will be routed through each processor until one throws an exception at which point the stage is advanced to the post processing stage .
237,522
public function fetchRequestMethod ( $ server = null ) { $ server || $ server = $ this -> _SERVER ; if ( isset ( $ _POST [ '_method' ] ) ) { if ( strtoupper ( $ _POST [ '_method' ] ) == 'PUT' || strtoupper ( $ _POST [ '_method' ] ) == 'PATCH' || strtoupper ( $ _POST [ '_method' ] ) == 'DELETE' ) { return strtoupper ( $...
Fetch the http method
237,523
public function parseCliArgs ( $ server = null ) { $ server || $ server = $ this -> _SERVER ; if ( ! isset ( $ server [ 'argv' ] ) ) { throw new \ Exception ( '$_SERVER["argv"] is not available' ) ; } $ args = array_slice ( $ server [ 'argv' ] , 1 ) ; return $ args ? '/' . implode ( '/' , $ args ) : '' ; }
Formats cli args like a uri
237,524
public function explodeSegments ( $ uri ) { $ segments = [ ] ; $ pattern = "|/*(.+?)/*$|" ; $ elements = explode ( "/" , preg_replace ( $ pattern , "\\1" , $ uri ) ) ; foreach ( $ elements as $ val ) { $ val = trim ( $ this -> filterUri ( $ val ) ) ; empty ( $ val ) || $ segments [ ] = $ val ; } return $ segments ; }
Explodes the uri string
237,525
static function write ( $ filename , $ contents , $ overwriteExisting = true ) { if ( file_exists ( $ filename ) && self :: isWritable ( $ filename ) ) { if ( $ overwriteExisting ) unlink ( $ filename ) ; } file_put_contents ( $ filename , $ contents ) ; }
Create or updates file
237,526
static function read ( $ filename ) { if ( file_exists ( $ filename ) && self :: isReadable ( $ filename ) ) { return file_get_contents ( $ filename ) ; } return NULL ; }
Gets the contents of a file
237,527
static function rename ( $ src , $ dest ) { if ( self :: exists ( $ dest ) ) { throw new \ Lollipop \ Exception \ Runtime ( 'File already exists: ' . $ dest ) ; } if ( is_uploaded_file ( $ src ) ) { return \ move_uploaded_file ( $ src , $ dest ) ; } return \ rename ( $ src , $ dest ) ; }
Alias rename file
237,528
public function isValid ( ) { if ( $ this -> isRequired ( ) ) { if ( $ this -> getValue ( ) == null ) return false ; if ( $ this -> getValue ( ) == "" ) return false ; } return true ; }
Validate value of control
237,529
protected function getCompiledAttributes ( $ prependClass = "" , $ skipValue = false ) { $ attrs = "" ; if ( $ this -> id ) $ attrs .= " id='$this->id'" ; $ attrs .= " class='$prependClass $this->class'" ; if ( $ this -> name ) $ attrs .= " name='$this->name'" ; if ( $ this -> placeholder ) $ attrs .= " placeholder='$t...
Compile the HTML attributes for using in the controls tag
237,530
public function searchSimpleFormAction ( ) { $ form = new SearchSimple ( $ this -> generateUrl ( 'home_autocomplete_name' ) ) ; return $ this -> render ( 'AnimeDbCatalogBundle:Home:searchSimpleForm.html.twig' , [ 'form' => $ this -> createForm ( $ form ) -> createView ( ) , ] ) ; }
Search simple form .
237,531
public function autocompleteNameAction ( Request $ request ) { $ response = $ this -> getCacheTimeKeeper ( ) -> getResponse ( 'AnimeDbCatalogBundle:Item' , - 1 , new JsonResponse ( ) ) ; if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } $ term = mb_strtolower ( $ request -> get ( 'term' ) , 'UTF8...
Autocomplete name .
237,532
public function searchAction ( Request $ request ) { $ response = $ this -> getCacheTimeKeeper ( ) -> getResponse ( [ 'AnimeDbCatalogBundle:Item' , 'AnimeDbCatalogBundle:Storage' ] ) ; if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } $ form = $ this -> createForm ( 'animedb_catalog_search' , new...
Search item .
237,533
public function settingsAction ( Request $ request ) { $ response = $ this -> getCacheTimeKeeper ( ) -> getResponse ( ) ; if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } $ entity = ( new GeneralEntity ( ) ) -> setTaskScheduler ( $ this -> container -> getParameter ( 'task_scheduler.enabled' ) )...
General settings .
237,534
public static function log ( $ message , $ options = array ( ) ) { if ( array_key_exists ( 'inputs' , $ options ) ) { $ inputs = $ options [ 'inputs' ] ; } else { $ inputs = array ( self :: getTimestamp ( ) , 'LOG' , self :: getFilename ( ) , self :: getLineNumber ( ) ) ; } if ( ! array_key_exists ( 'output' , $ option...
Output log message
237,535
public static function warn ( $ message , $ options = array ( ) ) { $ options [ 'inputs' ] = array ( self :: getTimestamp ( ) , 'WARN' , self :: getFilename ( ) , self :: getLineNumber ( ) ) ; self :: log ( $ message , $ options ) ; }
Output warn message
237,536
public function createUserFromOAuth ( $ data ) { $ user = $ this -> createUser ( ) ; $ user -> setAuthDataByProvider ( $ data [ 'provider' ] , [ 'id' => $ data [ 'id' ] , 'token' => $ data [ 'token' ] ] ) ; $ user -> setAuthProvider ( $ data [ 'provider' ] ) ; $ user -> setFirstAuthProvider ( $ data [ 'provider' ] ) ; ...
Creates a new User from oAuth data
237,537
public function updateFromGeoIp ( User $ user , array $ ipInfo ) { $ contact = $ user -> getContact ( ) ; $ country = $ contact -> getCountry ( ) ; $ city = $ contact -> getCity ( ) ; $ region = $ contact -> getRegion ( ) ; if ( ! $ country ) { $ contact -> setCountry ( $ ipInfo [ 'country' ] ) ; } if ( ! $ city ) { $ ...
Update User contact data from geoIp
237,538
public function signupLog ( User $ user , array $ ipInfo ) { $ user -> setAttribute ( 'signupIp' , $ ipInfo ) ; $ this -> dm -> persist ( $ user ) ; $ this -> dm -> flush ( ) ; return $ this ; }
Set signup attributes for geoIp on signup
237,539
public function loginLog ( User $ user , array $ geoIp ) { $ geoIp [ 'date' ] = date ( 'Y-m-d H:i:s' ) ; $ loginIps = $ user -> getAttribute ( 'lastLoginIps' ) ; if ( ! $ loginIps ) { $ loginIps = [ ] ; } array_unshift ( $ loginIps , $ geoIp ) ; $ loginIps = array_slice ( $ loginIps , 0 , 3 ) ; $ user -> setAttribute (...
Save login geoIp last 20 events
237,540
public function setLocale ( User $ user , $ locale ) { $ user -> getContact ( ) -> setLocale ( $ locale ) ; $ this -> dm -> persist ( $ user ) ; $ this -> dm -> flush ( ) ; return $ this ; }
Set locale for an user
237,541
public function enableRememberMe ( $ user ) { $ rememberMeValue = $ this -> generateRememberMeCookie ( $ user -> getUsername ( ) ) ; $ this -> session -> set ( 'REMEMBER_ME' , $ rememberMeValue ) ; }
Enable Remember Me feature
237,542
protected function generateRememberMeCookie ( $ username ) { $ key = 'ThisTokenIsNotSoSecretChangeIt' ; $ class = 'WobbleCode\UserBundle\Document\User' ; $ password = 'none' ; $ expires = time ( ) + 2592000 ; $ hash = hash ( 'sha256' , $ class . $ username . $ expires . $ password . $ key ) ; return $ this -> encodeCoo...
Generate remember me cookie final value
237,543
public function ip ( $ return_type = null , $ ip_addresses = [ ] ) { $ ip_elements = array ( 'HTTP_X_FORWARDED_FOR' , 'HTTP_FORWARDED_FOR' , 'HTTP_X_FORWARDED' , 'HTTP_FORWARDED' , 'HTTP_X_CLUSTER_CLIENT_IP' , 'HTTP_CLUSTER_CLIENT_IP' , 'HTTP_X_CLIENT_IP' , 'HTTP_CLIENT_IP' , 'REMOTE_ADDR' ) ; foreach ( $ ip_elements a...
Get client ip address
237,544
public function insert ( $ query , array $ data ) { $ this -> conn -> prepare ( $ query ) -> execute ( $ data ) ; return $ this -> conn -> lastInsertId ( ) ; }
Insert a record in the storage
237,545
public function update ( $ query , array $ data ) { $ stmt = $ this -> executeQuery ( $ query , $ data ) ; return $ stmt -> rowCount ( ) ; }
Update an existing record in the storage
237,546
public function delete ( $ query , array $ data ) { $ stmt = $ this -> executeQuery ( $ query , $ data ) ; return $ stmt -> rowCount ( ) ; }
Delete a record in the storage
237,547
public function findOne ( $ query , array $ data = null ) { $ stmt = $ this -> executeQuery ( $ query , $ data ) ; return $ stmt -> fetch ( \ PDO :: FETCH_ASSOC ) ; }
Fetch a record from the storage
237,548
public function findMany ( $ query , array $ data = null ) { $ stmt = $ this -> executeQuery ( $ query , $ data ) ; return ( $ stmt -> fetchAll ( \ PDO :: FETCH_ASSOC ) ) ; }
Fetch all records from a certain location in the storage
237,549
private function executeQuery ( $ query , $ data = null ) { $ stmt = $ this -> conn -> prepare ( $ query ) ; $ stmt -> execute ( $ data ) ; return $ stmt ; }
Execute a raw query
237,550
public static function each ( array $ set , Closure $ callback , $ recursive = true ) { foreach ( $ set as $ key => $ value ) { if ( is_array ( $ value ) && $ recursive ) { $ set [ $ key ] = static :: each ( $ value , $ callback , $ recursive ) ; } else { $ set [ $ key ] = $ callback ( $ value , $ key ) ; } } return $ ...
Calls a function for each key - value pair in the set . If recursive is true will apply the callback to nested arrays as well .
237,551
public static function every ( array $ set , Closure $ callback ) { foreach ( $ set as $ key => $ value ) { if ( ! $ callback ( $ value , $ key ) ) { return false ; } } return true ; }
Returns true if every element in the array satisfies the provided testing function .
237,552
public static function expand ( array $ set ) { $ data = array ( ) ; foreach ( $ set as $ key => $ value ) { $ data = static :: insert ( $ data , $ key , $ value ) ; } return $ data ; }
Expand an array to a fully workable multi - dimensional array where the values key is a dot notated path .
237,553
public static function extract ( array $ set , $ path ) { if ( ! $ set ) { return null ; } if ( strpos ( $ path , '.' ) === false ) { return isset ( $ set [ $ path ] ) ? $ set [ $ path ] : null ; } $ search = & $ set ; $ paths = explode ( '.' , ( string ) $ path ) ; $ total = count ( $ paths ) ; while ( $ total > 0 ) {...
Extract the value of an array depending on the paths given represented by key . key . key notation .
237,554
public static function flatten ( array $ set , $ path = null ) { if ( $ path ) { $ path = $ path . '.' ; } $ data = array ( ) ; foreach ( $ set as $ key => $ value ) { if ( is_array ( $ value ) ) { if ( $ value ) { $ data += static :: flatten ( $ value , $ path . $ key ) ; } else { $ data [ $ path . $ key ] = null ; } ...
Flatten a multi - dimensional array by returning the values with their keys representing their previous pathing .
237,555
public static function inject ( array $ set , $ path , $ value ) { if ( static :: has ( $ set , $ path ) ) { return $ set ; } return static :: insert ( $ set , $ path , $ value ) ; }
Includes the specified key - value pair in the set if the key doesn t already exist .
237,556
public static function insert ( array $ set , $ path , $ value ) { if ( ! $ path ) { return $ set ; } if ( strpos ( $ path , '.' ) === false ) { $ set [ $ path ] = $ value ; return $ set ; } $ search = & $ set ; $ paths = explode ( '.' , $ path ) ; $ total = count ( $ paths ) ; while ( $ total > 0 ) { $ key = $ paths [...
Inserts a value into the array set based on the given path .
237,557
public static function keyOf ( array $ set , $ match ) { $ return = null ; $ isArray = array ( ) ; foreach ( $ set as $ key => $ value ) { if ( $ value === $ match ) { $ return = $ key ; } if ( is_array ( $ value ) ) { $ isArray [ ] = $ key ; } } if ( ! $ return && $ isArray ) { foreach ( $ isArray as $ key ) { if ( $ ...
Returns the key of the specified value . Will recursively search if the first pass doesn t match .
237,558
public static function pluck ( array $ set , $ path ) { $ data = array ( ) ; foreach ( $ set as $ array ) { if ( $ value = static :: extract ( $ array , $ path ) ) { $ data [ ] = $ value ; } } return $ data ; }
Pluck a value out of each child - array and return an array of the plucked values .
237,559
public static function reduce ( array $ set , array $ keys ) { $ array = array ( ) ; foreach ( $ set as $ key => $ value ) { if ( in_array ( $ key , $ keys ) ) { $ array [ $ key ] = $ value ; } } return $ array ; }
Reduce an array by removing all keys that have not been defined for persistence .
237,560
public static function set ( array $ set , $ path , $ value = null ) { if ( is_array ( $ path ) ) { foreach ( $ path as $ key => $ value ) { $ set = static :: insert ( $ set , $ key , $ value ) ; } } else { $ set = static :: insert ( $ set , $ path , $ value ) ; } return $ set ; }
Set a value into the result set . If the paths is an array loop over each one and insert the value .
237,561
public static function some ( array $ set , Closure $ callback ) { foreach ( $ set as $ value ) { if ( $ callback ( $ value , $ value ) ) { return true ; } } return false ; }
Returns true if at least one element in the array satisfies the provided testing function .
237,562
public function moveFile ( $ file , $ model ) { $ path = $ this -> getUploadPath ( $ model , $ this -> options ) ; $ this -> makeDirectoryBeforeUpload ( $ path , true ) ; if ( ! is_null ( $ this -> elfinderFilePath ) ) { $ this -> copy ( $ this -> elfinderFilePath , $ path . '/' . $ this -> fileName ) ; } else { $ this...
move upload file
237,563
protected function setFileName ( $ file ) { if ( isset ( $ this -> options [ 'thumbnails' ] ) ) { $ thumbs = isset ( $ this -> options [ 'changeThumb' ] ) ? $ this -> options [ 'thumbnails' ] [ $ this -> options [ 'changeThumb' ] ] : $ this -> options [ 'thumbnails' ] ; $ thumbs = array_values ( $ thumbs ) ; $ firstThu...
set file name
237,564
protected function setFileSize ( $ file ) { $ this -> fileSize = ! is_null ( $ this -> elfinderFilePath ) ? $ this -> getFileSize ( ) : ( is_string ( $ file ) ? $ this -> size ( $ file ) : $ file -> getClientSize ( ) ) ; }
set file size
237,565
public function createFileName ( $ file ) { if ( ! is_null ( $ this -> elfinderFilePath ) ) { return $ this -> getFileName ( ) ; } if ( is_string ( $ file ) ) { return substr ( strrchr ( $ file , '/' ) , 1 ) ; } $ filename = $ file -> getClientOriginalName ( ) ; $ mime = $ file -> getClientOriginalExtension ( ) ; $ par...
create file name
237,566
protected function getFile ( $ request ) { $ columns = explode ( '.' , $ this -> options [ 'column' ] ) ; $ column = count ( $ columns ) > 1 ? $ columns [ 1 ] : $ columns [ 0 ] ; $ inputName = isset ( $ this -> options [ 'group' ] ) ? "{$this->options['group']}.{$this->options['index']}.{$column}" : $ column ; $ inputN...
get file or string path
237,567
public function getFileName ( ) { $ filename = substr ( strrchr ( $ this -> elfinderFilePath , '/' ) , 1 ) ; $ parts = explode ( '.' , $ filename ) ; $ last = array_pop ( $ parts ) ; $ filename = str_slug ( implode ( '_' , $ parts ) ) . '_' . time ( ) ; return $ filename . '.' . $ last ; }
get file name of the elfinder file
237,568
public function getDatas ( $ request ) { $ relation = $ this -> options [ 'relation' ] ; $ columnParams = explode ( '.' , $ this -> options [ 'column' ] ) ; if ( ! $ relation ) { return [ 'relation_type' => 'not' , 'datas' => [ $ columnParams [ 0 ] => $ this -> fileName , 'size' => $ this -> fileSize ] ] ; } $ datas = ...
get datas for save the database
237,569
public function deletePhoto ( $ model , $ parentRelation = null ) { $ thumbs = $ this -> options [ 'photo' ] [ 'thumbnails' ] ; $ id = is_null ( $ parentRelation ) ? $ model -> id : $ model -> $ parentRelation -> id ; $ path = $ this -> options [ 'photo' ] [ 'path' ] . "/{$id}" ; $ this -> delete ( $ path . "/original/...
delete file with model path
237,570
public function deleteDirectories ( $ model , $ parentRelation = null ) { $ id = is_null ( $ parentRelation ) ? $ model -> id : $ model -> $ parentRelation -> id ; foreach ( $ this -> options as $ option ) { $ this -> deleteDirectory ( $ option [ 'path' ] . "/{$id}" ) ; } }
delete multiple directories with model path
237,571
public function makeDirectoryBeforeUpload ( $ path , $ cleanDirectory = false ) { if ( ! $ this -> exists ( $ path ) ) { $ this -> makeDirectory ( $ path , 0775 , true ) ; return true ; } if ( ( $ this -> exists ( $ path ) && $ cleanDirectory ) || ( isset ( $ this -> options [ 'is_reset' ] ) && $ this -> options [ 'is_...
if not exists make directory or clean directory
237,572
public function staticProperty ( $ class , $ property , $ args = array ( ) ) { if ( ! class_exists ( $ class ) ) return null ; if ( ! property_exists ( $ class , $ property ) ) return null ; $ vars = get_class_vars ( $ class ) ; return $ vars [ $ property ] ; }
Calls a static method on the given class
237,573
public function start ( InputInterface $ input = null , OutputInterface $ output = null ) : int { return ContainerScope :: runScope ( $ this -> container , function ( ) use ( $ input , $ output ) { return $ this -> getApplication ( ) -> run ( $ input , $ output ) ; } ) ; }
Run console application .
237,574
public function run ( ? string $ command , $ input = [ ] , OutputInterface $ output = null ) : CommandOutput { if ( is_array ( $ input ) ) { $ input = new ArrayInput ( $ input + compact ( 'command' ) ) ; } $ output = $ output ?? new BufferedOutput ( ) ; $ command = $ this -> getApplication ( ) -> find ( $ command ) ; $...
Run selected command .
237,575
public function getApplication ( ) : Application { if ( ! empty ( $ this -> application ) ) { return $ this -> application ; } $ this -> application = new Application ( $ this -> config -> getName ( ) , $ this -> config -> getVersion ( ) ) ; $ this -> application -> setCatchExceptions ( false ) ; $ this -> application ...
Get associated Symfony Console Application .
237,576
protected function format ( ) { $ number = $ this -> getParameter ( 'number' ) ; if ( $ number instanceof Meta ) { $ number = $ number -> getValue ( ) ; } if ( empty ( $ number ) || ! is_numeric ( $ number ) ) { return 0 ; } $ decimals = $ this -> getParameter ( 'decimals' ) ; $ decimal_sep = $ this -> getParameter ( '...
wrapper for number_format
237,577
protected function bound ( ) { $ number = $ this -> getParameter ( 'number' ) ; $ min = $ this -> getParameter ( 'min' ) ; $ max = $ this -> getParameter ( 'max' ) ; if ( $ number instanceof Meta ) { $ number = $ number -> getValue ( ) ; } return NumberUtils :: bound ( $ number , $ min , $ max ) ; }
Return a number within a range .
237,578
public function create ( $ id , ContainerInterface $ container ) { if ( isset ( $ this -> registeredList [ 'services' ] [ $ id ] ) ) { $ data = $ this -> createService ( $ id , $ container ) ; } elseif ( isset ( $ this -> registeredList [ 'params' ] [ $ id ] ) ) { $ data = $ this -> registeredList [ 'params' ] [ $ id ]...
Create service or parameter based on configured dependencies .
237,579
public function createResolver ( $ namespace , $ resolution , $ newInstance = false ) { if ( ! $ this -> hasResolution ( $ namespace ) ) { if ( $ newInstance ) { $ resolution = [ $ resolution , true ] ; } $ this -> registeredList [ 'resolves' ] [ $ namespace ] = $ resolution ; } }
Resolve a given namespace to given resolution .
237,580
public function resolveAndCreate ( $ namespace , ContainerInterface $ container ) { $ class = new \ ReflectionClass ( $ namespace ) ; $ arguments = $ this -> resolveReflectionArguments ( $ class , $ container ) ; return $ class -> newInstanceArgs ( $ arguments ) ; }
Instantiate a new object using constructor injection .
237,581
public function processNodes ( DOMNode $ node ) { $ allLinkNodes = $ this -> xp -> query ( './/a' , $ node ) ; $ allLinkNodesSortedByLength = [ ] ; foreach ( $ allLinkNodes as $ linkNode ) { $ allLinkNodesSortedByLength [ ] = [ 'href' => $ linkNode -> getAttribute ( 'href' ) , 'node' => $ linkNode , ] ; } usort ( $ all...
Process node .
237,582
public function filterRange ( $ range ) { if ( is_int ( $ range ) ) { $ level = $ range ; $ depth = 0 ; } else { reset ( $ range ) ; $ level = key ( $ range ) ; $ depth = current ( $ range ) ; } if ( 1 === $ level ) { $ nodeList = $ this -> xp -> query ( '/descendant-or-self::*[ name() = "ul" and count( ancestor-or-sel...
Restrict navigation to given range .
237,583
public function filterBreadcrumb ( ) { $ nodeList = $ this -> xp -> query ( '//li[ contains(@class, "open") or contains(@class, "active")]' ) ; if ( 0 !== $ nodeList -> length ) { $ ul = $ this -> dom -> createElement ( 'ul' ) ; foreach ( $ nodeList as $ node ) { $ li = $ this -> dom -> createElement ( 'li' ) ; $ li ->...
Create breadcrumb for current page .
237,584
public static function render ( $ navigationFile , $ requestedUri = false , $ options = null ) { $ instance = new Navigation ( $ navigationFile , $ requestedUri ) ; if ( $ options ) { if ( isset ( $ options [ 'breadcrumb' ] ) ) { $ temp = $ instance -> filterBreadcrumb ( ) ; if ( $ temp ) { return $ instance -> dom -> ...
Static helper function to render Navigation .
237,585
public function sites ( ) { if ( ! class_exists ( \ Modules \ Site \ Entities \ Page :: class , false ) ) { throw new \ Exception ( 'in order to use User::sites() you have to install the \'vain-sites\' module' ) ; } return $ this -> hasMany ( \ Modules \ Site \ Entities \ Page :: class ) ; }
created static pages .
237,586
public function scopeOnline ( $ query ) { $ expiryDate = Carbon :: now ( ) -> subMinutes ( config ( 'session.lifetime' ) ) ; return $ query -> where ( 'last_active_at' , '>' , $ expiryDate ) -> andWhere ( 'logged_out' , false ) ; }
queries all possible online users .
237,587
public function getOnlineAttribute ( $ value ) { $ expiryDate = Carbon :: now ( ) -> subMinutes ( config ( 'session.lifetime' ) ) ; return ( ! $ this -> logged_out ) && $ expiryDate -> lt ( $ this -> last_active_at ) ; }
accessor for current online state .
237,588
public function saveWithoutTimestamps ( array $ options = [ ] ) { $ this -> timestamps = false ; $ this -> save ( $ options ) ; $ this -> timestamps = true ; }
Save the model to the database without updating the timestamps .
237,589
private function getCountryCode ( ) { $ posted = $ this -> appRequest -> getPostValue ( ) ; if ( isset ( $ posted [ 'customer' ] [ ABlock :: TMPL_FLDGRP ] [ ABlock :: TMPL_FIELD_COUNTRY_CODE ] ) ) { $ result = $ posted [ 'customer' ] [ ABlock :: TMPL_FLDGRP ] [ ABlock :: TMPL_FIELD_COUNTRY_CODE ] ; } else { $ result = ...
Extract code for customer s registration country from posted data .
237,590
private function getMlmId ( $ customer ) { $ posted = $ this -> appRequest -> getPostValue ( ) ; if ( isset ( $ posted [ 'customer' ] [ ABlock :: TMPL_FLDGRP ] [ ABlock :: TMPL_FIELD_OWN_MLM_ID ] ) && ! empty ( $ posted [ 'customer' ] [ ABlock :: TMPL_FLDGRP ] [ ABlock :: TMPL_FIELD_OWN_MLM_ID ] ) ) { $ result = $ post...
Extract customer s MLM ID from posted data or generate new one .
237,591
private function getParentId ( ) { $ posted = $ this -> appRequest -> getPostValue ( ) ; if ( isset ( $ posted [ 'customer' ] [ ABlock :: TMPL_FLDGRP ] [ ABlock :: TMPL_FIELD_PARENT_MLM_ID ] ) ) { $ mlmId = $ posted [ 'customer' ] [ ABlock :: TMPL_FLDGRP ] [ ABlock :: TMPL_FIELD_PARENT_MLM_ID ] ; $ found = $ this -> da...
Extract customer s parent ID from posted data or set null to extract it in service later from referral code .
237,592
public static function findExistingReferences ( $ model , $ field ) { $ invalid = true ; $ uniqueString = null ; while ( $ invalid == true ) { $ uniqueString = Str :: random ( $ model :: $ uniqueStringLimit ) ; $ existingReferences = $ model :: where ( $ field , $ uniqueString ) -> count ( ) ; if ( $ existingReferences...
Make sure the uniqueId is always unique .
237,593
public function setDirectory ( $ directory ) { if ( class_exists ( '\Latte\Engine' , true ) ) { $ this -> latte = new Latte ; $ this -> latte -> setTempDirectory ( realpath ( Core :: $ tempDir . DS . 'Latte' ) ) ; } else { throw new LayoutException ( "Could not load LatteEngine. Is it installed or Composer not loaded?"...
Set the directory of the current template .
237,594
public function set ( string $ abstract , $ concrete , $ singleton = false ) { if ( $ this -> has ( $ abstract ) ) { throw new ContainerException ( sprintf ( 'An entry with the id "%s" already exists.' , $ abstract ) ) ; } $ this -> bindings [ $ abstract ] = new ContainerEntry ( $ abstract , $ concrete , $ singleton ) ...
Bind a abstract to a concrete . If the concrete is a object and not a string it will be stored as it is .
237,595
public static function snippet ( string $ text , int $ length = 150 ) { $ breakerPos = mb_strpos ( $ text , self :: WYSIWYG_BREAK_HTML , null , 'UTF-8' ) ; if ( $ breakerPos !== false ) { $ text = Str :: sub ( $ text , 0 , $ breakerPos ) ; } else { $ breakerPos = mb_strpos ( $ text , '</p>' , null , 'UTF-8' ) ; if ( $ ...
Make snippet from text or html - text content .
237,596
protected function assignEntity ( $ entity ) { $ entityClass = $ this -> model -> entity ( ) ; if ( $ entity === null ) { throw new QueryException ( sprintf ( 'Missing required entity of class "%s"' , $ entityClass ) ) ; } if ( ! is_array ( $ entity ) && ! $ entity instanceof $ entityClass ) { throw new QueryException ...
Assigns entity instance Asserts if entity instance is of expected type
237,597
protected function setPrimaryKeyConditions ( ) { foreach ( $ this -> model -> primaryFields ( ) as $ field ) { $ value = $ this -> accessor -> getPropertyValue ( $ this -> instance , $ field -> name ( ) ) ; $ this -> builder -> andWhere ( sprintf ( '%s = %s' , $ this -> connection -> quoteIdentifier ( $ field -> mapped...
Assigns primary condition
237,598
public function clearToken ( $ service ) { $ service = $ this -> normalizeServiceName ( $ service ) ; $ tokens = $ this -> sessionScope -> get ( self :: SESSION_TOKEN ) ; if ( array_key_exists ( $ service , $ tokens ) ) { unset ( $ tokens , $ service ) ; } $ this -> sessionScope -> set ( self :: SESSION_TOKEN , $ token...
Delete the users token . Aka log out .
237,599
public function hasAuthorizationState ( $ service ) { $ service = $ this -> normalizeServiceName ( $ service ) ; $ states = $ this -> sessionScope -> get ( self :: SESSION_STATE ) ; return isset ( $ states [ $ service ] ) ; }
Check if an authorization state for a given service exists