idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
29,400
public function setRemoteEntry ( Entry $ remoteEntry ) : void { $ this -> remoteEntry = $ remoteEntry ; $ this -> id = $ this -> remoteEntry -> getSpace ( ) -> getId ( ) . '|' . $ this -> remoteEntry -> getId ( ) ; $ contentType = $ this -> remoteEntry -> getContentType ( ) ; if ( $ contentType === null ) { return ; } $ nameField = $ contentType -> getDisplayField ( ) ; if ( $ nameField === null ) { return ; } $ callable = [ $ remoteEntry , 'get' . $ nameField -> getId ( ) ] ; $ this -> name = call_user_func ( $ callable ) ; }
Sets the remote entry .
29,401
public function reviveRemoteEntry ( Client $ client ) : void { $ remoteEntry = $ client -> parseJson ( $ this -> json ) ; $ this -> id = $ remoteEntry -> getSpace ( ) -> getId ( ) . '|' . $ remoteEntry -> getId ( ) ; $ contentType = $ remoteEntry -> getContentType ( ) ; if ( $ contentType === null ) { return ; } $ nameField = $ contentType -> getDisplayField ( ) ; if ( $ nameField === null ) { return ; } $ callable = [ $ remoteEntry , 'get' . $ nameField -> getId ( ) ] ; $ this -> name = call_user_func ( $ callable ) ; $ this -> remoteEntry = $ remoteEntry ; }
Revives the remote entry from provided client .
29,402
public static function create ( $ className , $ arguments = null , $ constructor = 'getInstance' , $ reflection = null ) { if ( is_null ( $ arguments ) ) { return call_user_func ( $ className . '::' . $ constructor ) ; } else { if ( is_array ( $ arguments ) ) { return call_user_func_array ( $ className . '::' . $ constructor , $ arguments ) ; } else { return call_user_func ( $ className . '::' . $ constructor , $ arguments ) ; } } }
This method is intend to create instances of singleton - classes . You can pass optional arguments to the factory for creating instance and passing arguments to it .
29,403
public function transform ( $ value ) { if ( null === $ value ) { return '' ; } if ( ! is_numeric ( $ value ) ) { throw new UnexpectedTypeException ( $ value , 'numeric' ) ; } $ formatter = $ this -> getNumberFormatter ( \ NumberFormatter :: CURRENCY ) ; $ value /= $ this -> divisor ; if ( null !== $ this -> currency ) { $ value = $ formatter -> formatCurrency ( $ value , $ this -> currency ) ; } else { $ value = $ formatter -> format ( $ value ) ; } if ( 0 !== $ formatter -> getErrorCode ( ) ) { throw new TransformationFailedException ( $ formatter -> getErrorMessage ( ) ) ; } return $ value ; }
Transforms a number type into localized money .
29,404
public function add ( $ parameter , array $ array ) { if ( ! isset ( $ this -> $ parameter ) ) { throw new \ Exception ( "Supplied variable doesn't exist" ) ; } $ array [ $ this -> callingClassWithoutNamespace ( ) ] = $ this ; $ up = ucfirst ( $ parameter ) ; $ object = ( dirname ( get_class ( ) ) . "\\" . $ up ) ; $ object = new $ object ( ) ; if ( ! $ object instanceof ArraySerialize ) { throw new \ Exception ( "Object supplied not serialisable" ) ; } $ object -> fromArray ( $ array , $ object ) ; unset ( $ array [ $ this -> callingClassWithoutNamespace ( ) ] ) ; $ this -> $ parameter -> add ( $ object ) ; }
Hide one To Many adding of a new entity
29,405
public function addTextField ( FormBuilderInterface $ builder , string $ name , array $ options ) { $ builder -> add ( strtolower ( $ name ) , TextType :: class , array_merge_recursive ( array ( "required" => false ) , $ options ) ) ; return $ this ; }
Add Text Field to Edit Form
29,406
public function buildForm ( FormBuilderInterface $ builder , array $ options ) { $ this -> getEventDispatcher ( ) -> dispatch ( FormListingEvent :: NAME , new FormListingEvent ( $ builder , $ options ) ) ; }
Build Connector Edit Form
29,407
public function run ( $ data , $ id = null ) { $ this -> hr ( ) ; $ this -> out ( __d ( 'cake_settings_app' , 'CakePHP Queue clearing cache task.' ) ) ; $ queueLength = $ this -> QueueInfo -> getLengthQueue ( 'ClearCache' ) ; if ( $ queueLength > 0 ) { $ this -> out ( __d ( 'cake_settings_app' , 'Found clearing cache task in queue: %d. Skipped.' , $ queueLength ) ) ; return true ; } $ cacheConfigs = Cache :: configured ( ) ; foreach ( $ cacheConfigs as $ cacheConfigName ) { Cache :: clear ( false , $ cacheConfigName ) ; } $ this -> QueuedTask -> updateProgress ( $ id , 1 ) ; return true ; }
Main function . Used for clear cache .
29,408
public static function isTaken ( ? array $ data = [ ] ) { if ( count ( $ data ) == 1 ) { foreach ( $ data as $ field => $ value ) { return self :: where ( $ field , $ value ) -> first ( ) == null ? false : true ; } } $ response = array ( ) ; foreach ( $ data as $ field => $ value ) { $ check = self :: where ( $ field , $ value ) -> first ( ) ; $ response = array_merge ( $ response , array ( $ field => $ check == null ? false : true ) ) ; } return $ response ; }
Check if value is taken
29,409
public function keyCheck ( $ apiKey = null , $ url = null ) { if ( $ apiKey === null || $ url === null ) { throw new InvalidArgumentException ( 'Both apiKey and site URL cannot be null' ) ; } return $ this -> connection -> keyCheck ( $ apiKey , $ url ) ; }
Allows to manually check if API key is valid or not
29,410
public function getSalutation ( ) { if ( $ this -> getGender ( ) === self :: GENDER_MALE && $ this -> getLastName ( ) ) { return 'Sehr geehrter Herr ' . $ this -> getLastName ( ) ; } elseif ( $ this -> getGender ( ) === self :: GENDER_FEMALE && $ this -> getLastName ( ) ) { return 'Sehr geehrte Frau ' . $ this -> getLastName ( ) ; } return 'Sehr geehrte Damen und Herren' ; }
Create salutation string
29,411
public function getFormOfAddress ( ) { if ( $ this -> getGender ( ) === self :: GENDER_MALE && $ this -> getLastName ( ) ) { return 'Herr ' . $ this -> getFirstName ( ) . ' ' . $ this -> getLastName ( ) ; } elseif ( $ this -> getGender ( ) === self :: GENDER_FEMALE && $ this -> getLastName ( ) ) { return 'Frau ' . $ this -> getFirstName ( ) . ' ' . $ this -> getLastName ( ) ; } return '' ; }
Create address string
29,412
protected function getCommands ( ) { $ commands = [ ] ; $ routes = $ this -> map -> getRoutes ( ) ; ksort ( $ routes ) ; $ text = '' ; foreach ( $ routes as $ route ) { $ name = $ route -> name ; $ summary = $ this -> getCommandSummary ( $ route ) ; $ text .= " {$name}" . PHP_EOL ; $ text .= " {$summary}" . PHP_EOL ; } return "<<bold>>COMMANDS<<reset>>" . PHP_EOL . " " . trim ( $ text ) . PHP_EOL . PHP_EOL ; }
Get command index listing
29,413
protected function getCommandSummary ( Route $ route ) { $ input = $ this -> resolve ( $ route -> input ) ; if ( ! $ input instanceof HelpAwareInterface ) { return 'No description' ; } $ input -> help ( $ this -> help ) ; return $ this -> help -> getSummary ( ) ; }
Get command summary
29,414
private function hasProperty ( string $ name ) : bool { if ( ! isset ( $ this -> index [ PropertyBinding :: TYPE ] ) ) { return false ; } return $ this -> index [ PropertyBinding :: TYPE ] -> hasProperty ( $ name ) ; }
checks whether property with given name is available
29,415
public function hasExplicitBinding ( string $ type , $ name = null ) : bool { if ( PropertyBinding :: TYPE === $ type ) { return $ this -> hasProperty ( $ name ) ; } $ bindingName = $ this -> bindingName ( $ name ) ; if ( null !== $ bindingName && isset ( $ this -> index [ $ type . '#' . $ bindingName ] ) ) { return true ; } if ( isset ( $ this -> index [ $ type ] ) ) { return true ; } return false ; }
check whether an excplicit binding for a type is available
29,416
public function getInstance ( string $ type , $ name = null ) { if ( __CLASS__ === $ type ) { return $ this ; } array_push ( $ this -> injectionStack , $ type . '#' . $ name ) ; $ instance = $ this -> getBinding ( $ type , $ name ) -> getInstance ( $ this , $ name ) ; array_pop ( $ this -> injectionStack ) ; return $ instance ; }
get an instance
29,417
public function get ( $ alias ) { return isset ( $ this -> services [ $ alias ] ) ? $ this -> services [ $ alias ] : null ; }
Get a tagged service from its alias
29,418
public function index ( Request $ request ) { $ posts = Post :: all ( ) ; $ bestTag = Tag :: with ( 'postCount' ) -> get ( ) -> sortByDesc ( 'postCount' ) ; $ bestCat = Category :: with ( 'postCount' ) -> get ( ) -> sortByDesc ( 'postCount' ) ; \ Debugbar :: info ( $ bestTag ) ; return view ( 'maikblog::table' , [ 'posts' => $ posts , 'best_tag' => $ bestTag , 'best_cat' => $ bestCat , ] ) ; }
Display a list of all blog post to admin .
29,419
public static function push ( $ user , $ templates , $ context ) { if ( defined ( 'IN_UNIT_TESTS' ) ) { return ; } foreach ( $ templates as $ engineName => $ template ) { $ engineClass = 'User_Notify_Engine_' . $ engineName ; $ engine = new $ engineClass ( ) ; $ engine -> push ( $ user , $ template , $ context ) ; } }
Push message for the user
29,420
function withRequestOnMatch ( RequestInterface $ request ) { $ requestTarget = $ request -> getRequestTarget ( ) ; $ requestTarget = new StdString ( $ requestTarget ) ; $ requestTarget = $ requestTarget -> stripPrefix ( rtrim ( $ this -> _stripPrefix , '/' ) ) ; $ request = $ request -> withRequestTarget ( ( string ) $ requestTarget ) ; return $ request ; }
Prepare Request Object
29,421
public function generateViewFile ( $ content ) { $ name = $ this -> getRandomName ( ) ; $ path = sys_get_temp_dir ( ) ; $ filename = $ path . '/' . $ name . '.twig' ; if ( ! file_exists ( dirname ( $ filename ) ) ) { mkdir ( dirname ( $ filename ) , 0755 , true ) ; } file_put_contents ( $ filename , $ content ) ; return $ filename ; }
Generate a view file .
29,422
public function generateAndRender ( $ content , $ data ) { $ filename = $ this -> generateViewFile ( $ content ) ; try { $ rendered = $ this -> render ( $ filename , $ data ) ; } catch ( \ Exception $ e ) { $ this -> remove ( $ filename ) ; throw $ e ; } $ this -> remove ( $ filename ) ; return $ rendered ; }
Generate a file and renderd it .
29,423
static public function addIgnores ( $ ignores ) { if ( ! is_array ( $ ignores ) ) { $ ignores = array ( $ ignores ) ; } foreach ( $ ignores as $ i ) { self :: $ ignore [ $ i ] = true ; } }
Allow code using ErrorHandler to customize where warnings can be safely suppressed .
29,424
static public function errorHandler ( $ errno , $ errstr , $ errfile = '' , $ errline = 0 , $ errcontext = array ( ) ) { if ( ! isset ( self :: $ ignore [ basename ( $ errfile ) . '-' . $ errline . '-' . $ errno ] ) ) { $ msg = $ errstr . ' Line ' . $ errline . ', ' . $ errfile ; self :: $ logger -> debug ( $ msg ) ; } return true ; }
Error handler function . Can register as PHP s error handling function and use Fannie s output format
29,425
static public function exceptionHandler ( $ exception ) { $ msg = $ exception -> getMessage ( ) . " Line " . $ exception -> getLine ( ) . ", " . $ exception -> getFile ( ) ; self :: $ logger -> debug ( $ msg ) ; }
Exception handler function . Can register as PHP s exception handling function and use Fannie s output format
29,426
public function referenceGetAction ( $ demAction ) { $ result = MageType :: REF_ACTION_NO_ACTION ; if ( $ demAction == DemType :: REF_ACTION_RESTRICT ) { $ result = MageType :: REF_ACTION_RESTRICT ; } else { if ( $ demAction == DemType :: REF_ACTION_CASCADE ) { $ result = MageType :: REF_ACTION_CASCADE ; } } return $ result ; }
Map DEM foreign keys actions to Varien values .
29,427
final public function getTableName ( ) { if ( $ this -> _tableName !== null ) return $ this -> _tableName ; $ exp = explode ( '\\' , get_called_class ( ) ) ; return \ Util :: camelTo_ ( $ exp [ count ( $ exp ) - 1 ] ) ; }
Fetches the name of the table to attach model to
29,428
public function populate ( array $ data ) { foreach ( $ data as $ property => $ value ) { $ property = \ Util :: _toCamel ( $ property ) ; $ method = 'set' . ucfirst ( $ property ) ; if ( method_exists ( $ this , $ method ) ) { $ this -> $ method ( $ value ) ; } elseif ( property_exists ( $ this , $ property ) ) { $ this -> $ property = $ value ; } } return $ this ; }
Populates the properties of the model from the given data
29,429
public function toArray ( ) { $ ppts = get_object_vars ( $ this ) ; unset ( $ ppts [ '_connection' ] ) ; unset ( $ ppts [ '_tableName' ] ) ; unset ( $ ppts [ '_by' ] ) ; unset ( $ ppts [ '_table' ] ) ; unset ( $ ppts [ '_content' ] ) ; return $ ppts ; }
Returns an array copy of the properties of the row and their values
29,430
final public function reset ( array $ contructorParameters = array ( ) ) { foreach ( array_keys ( $ this -> toArray ( ) ) as $ ppt ) { $ this -> $ ppt = null ; } if ( method_exists ( $ this , '__construct' ) ) { call_user_func_array ( array ( $ this , '__construct' ) , $ contructorParameters ) ; } return $ this ; }
Resets all properties of the model to null
29,431
private function prepSelectRelTable ( Table & $ relTable , array $ callArgs ) { foreach ( $ callArgs [ 0 ] as $ method => $ args ) { if ( $ method === 'where' ) continue ; if ( method_exists ( $ relTable , $ method ) ) { $ args = is_array ( $ args ) ? $ args : array ( $ args ) ; $ relTable = call_user_func_array ( array ( $ relTable , $ method ) , $ args ) ; } } return $ relTable ; }
Prepares the related table for select calling limit and orderBy if required
29,432
private function getRelTableModel ( array $ callArgs ) { if ( isset ( $ callArgs [ 'model' ] ) && is_object ( $ callArgs [ 'model' ] ) ) { return $ callArgs [ 'model' ] ; } else if ( isset ( $ callArgs [ 'model' ] ) && is_array ( $ callArgs [ 'model' ] ) && isset ( $ callArgs [ 'model' ] [ 'rowModel' ] ) ) { return $ callArgs [ 'model' ] [ 'rowModel' ] ; } return new Row ( ) ; }
Fetches the model to use for the called related table from the call arguments
29,433
private function getRelTableWhere ( array & $ callArgs , $ column , $ value ) { $ where = array ( ) ; if ( ! isset ( $ callArgs [ 0 ] ) || ( isset ( $ callArgs [ 0 ] ) && ! is_array ( $ callArgs [ 0 ] ) ) || ( isset ( $ callArgs [ 0 ] ) && is_array ( $ callArgs [ 0 ] ) && ! isset ( $ callArgs [ 0 ] [ 'where' ] ) ) ) { $ where [ ] = array ( $ column => $ value ) ; } else if ( ( isset ( $ callArgs [ 0 ] ) && is_array ( $ callArgs [ 0 ] ) && isset ( $ callArgs [ 0 ] [ 'where' ] ) ) ) { if ( is_array ( $ callArgs [ 0 ] [ 'where' ] ) ) { foreach ( $ callArgs [ 0 ] [ 'where' ] as $ row ) { if ( is_object ( $ row ) ) { $ row -> $ column = $ value ; } else if ( is_array ( $ row ) ) { $ row [ $ column ] = $ value ; } else { throw new \ Exception ( 'Related Table Call Error: Option where value must be an array of \DBScribe\Rows or array of columns to values' ) ; } $ where [ ] = $ row ; } } else if ( is_object ( $ row ) ) { $ row -> $ column = $ value ; $ where [ ] = $ row ; } unset ( $ callArgs [ 0 ] [ 'where' ] ) ; } return $ where ; }
Fetches the where values for the related table from the call arguments
29,434
public function configure ( $ identifier , $ lifetime , $ gcTime , $ useCookies ) { $ this -> identifier ( $ identifier ) -> lifetime ( $ lifetime ) -> gcTime ( $ gcTime ) -> useCookies ( $ useCookies ) ; }
Setup the basic configuration .
29,435
protected function init ( \ stdClass $ configuration ) { $ this -> configure ( $ configuration -> identifier , $ configuration -> lifetime , $ configuration -> gcTime , $ configuration -> useCookies ) ; if ( $ configuration -> security -> enabled ) { if ( $ configuration -> security -> encryption -> enabled ) { $ this -> enableEncryption ( $ configuration -> security -> encryption -> cipher , $ configuration -> security -> encryption -> encoding ) ; } else { $ this -> disableEncryption ( ) ; } } return $ this ; }
Basic initialization of session like configuring PHP .
29,436
protected function setSessionCookie ( $ identifier , $ sessionId , $ lifetime , $ path , $ domain , $ ssl , $ httpOnly = null ) { $ expire = time ( ) + $ lifetime ; if ( null !== $ httpOnly && $ this -> getFlagStatus ( 'httpOnly' ) ) { session_set_cookie_params ( $ lifetime , $ path , $ domain , $ ssl , $ httpOnly ) ; $ result = setcookie ( $ identifier , $ sessionId , $ expire , $ path , $ domain , $ ssl , $ httpOnly ) ; } else { session_set_cookie_params ( $ lifetime , $ path , $ domain , $ ssl ) ; $ result = setcookie ( $ identifier , $ sessionId , $ expire , $ path , $ domain , $ ssl ) ; } return $ result ; }
Configures the session cookie parameter .
29,437
protected function encrypt ( $ value ) { return $ this -> getCryptService ( ) -> encrypt ( serialize ( $ value ) , $ this -> getSecurity ( ) -> getPrivateKey ( ) ) ; }
returns an encrypted string for given input if encryption is enabled .
29,438
protected function getDotParts ( $ string , $ parts , $ direction = 'ltr' ) { if ( $ direction == 'ltr' ) { return implode ( '.' , array_slice ( explode ( '.' , $ string ) , 0 , $ parts ) ) ; } else { return implode ( '.' , array_slice ( explode ( '.' , $ string ) , ( substr_count ( $ string , '.' ) + 1 ) - $ parts , $ parts ) ) ; } }
Returns a part of the input string splitted by count of dots from left or right .
29,439
public function initSessionSecurity ( $ ssl = self :: DEFAULT_SEC_FLAG_SSL , $ httpOnly = self :: DEFAULT_SEC_FLAG_HTTPONLY ) { if ( $ ssl ) { $ this -> setSsl ( is_ssl ( ) && $ this -> getFlagStatus ( 'ssl' ) ) ; } else { $ this -> setSsl ( false ) ; } if ( $ httpOnly ) { $ this -> setHttpOnly ( $ this -> getFlagStatus ( 'httpOnly' ) ) ; } else { $ this -> setHttpOnly ( false ) ; } }
Setup security settings of session .
29,440
public function enableEncryption ( $ cipher = self :: DEFAULT_ENCRYPT_CIPHER , $ encoding = self :: DEFAULT_ENCRYPT_ENCODING ) { $ this -> cryptService ( Doozr_Loader_Serviceloader :: load ( 'crypt' , $ cipher , $ encoding ) ) -> security ( self :: getRegistry ( ) -> getSecurity ( ) ) ; $ this -> encrypt = true ; }
Enables encryption . This method is intend to enable the encryption for this instance including cipher and encoding .
29,441
public function handleRegenerate ( ) { if ( ! $ this -> wasStarted ( ) ) { throw new Doozr_Session_Service_Exception ( 'Error while handling Session regeneration! handleRegenerate() must be called after session start().' ) ; } if ( ( $ currentCycle = $ this -> mustRegenerate ( ) ) === true ) { $ this -> regenerate ( ) ; $ currentCycle = 0 ; } $ this -> set ( self :: DEFAULT_REGENERATE_CYCLES_IDENTIFIER , $ currentCycle ) ; }
Handle the regeneration process .
29,442
public function setFlagStatus ( $ flag , $ status ) { if ( is_array ( $ flag ) ) { foreach ( $ flag as $ singleFeature ) { $ this -> flags [ $ singleFeature ] = $ status ; } } else { $ this -> flags [ $ flag ] = $ status ; } }
Sets the status of a given flag .
29,443
public function getFlagStatus ( $ flag = null ) { if ( ! $ flag || ! isset ( $ this -> flags [ $ flag ] ) ) { return $ this -> flags ; } else { return $ this -> flags [ $ flag ] ; } }
Returns the status of a given flag .
29,444
public function set ( $ variable , $ value ) { if ( true === $ this -> hasEncryption ( ) ) { $ variable = $ this -> encrypt ( $ variable ) ; $ value = $ this -> encrypt ( $ value ) ; } $ _SESSION [ $ variable ] = $ value ; return true ; }
storages a given variable with value in session .
29,445
public function issetVariable ( $ variable ) { if ( true === $ this -> hasEncryption ( ) ) { $ variable = $ this -> encrypt ( $ variable ) ; } return ( true === isset ( $ _SESSION [ $ variable ] ) ) ; }
returns the isset status of variable .
29,446
public function unsetVariable ( $ variable ) { if ( true === $ this -> hasEncryption ( ) ) { $ variable = $ this -> encrypt ( $ variable ) ; } unset ( $ _SESSION [ $ variable ] ) ; return ( false === $ this -> issetVariable ( $ variable ) ) ; }
Unsets a variable from session .
29,447
public function getIdentifier ( ) { $ identifier = $ this -> identifier ; if ( true === $ this -> useObfuscation ( ) ) { $ headers = getallheaders ( ) ; $ filter = [ 'USER-AGENT' , 'ACCEPT' , 'ACCEPT-LANGUAGE' , 'ACCEPT-ENCODING' ] ; foreach ( $ headers as $ header => $ value ) { if ( false === in_array ( strtoupper ( $ header ) , $ filter ) ) { unset ( $ headers [ $ header ] ) ; } } $ identifier = sha1 ( $ identifier . $ this -> generateFingerprint ( $ this -> getClientIp ( ) , $ headers ) ) ; } return $ identifier ; }
Returns the identifier with implemented fingerprinting to ensure higher security .
29,448
public function setRegenerateCycles ( $ cycles = self :: DEFAULT_REGENERATE_CYCLES ) { $ this -> regenerateCycles = $ cycles ; if ( $ cycles > 0 ) { $ this -> callStack [ 'start' ] [ 'regenerate' ] = [ $ this , 'handleRegenerate' , ] ; } else { if ( isset ( $ this -> callStack [ 'start' ] [ 'regenerate' ] ) ) { unset ( $ this -> callStack [ 'start' ] [ 'regenerate' ] ) ; } } }
Configures the regeneration of the Session - Id by given cycles .
29,449
public function mustRegenerate ( ) { try { $ currentCycle = $ this -> get ( self :: DEFAULT_REGENERATE_CYCLES_IDENTIFIER ) ; } catch ( Doozr_Session_Service_Exception $ e ) { $ currentCycle = 0 ; } ++ $ currentCycle ; if ( $ currentCycle == $ this -> getRegenerateCycles ( ) ) { return true ; } return $ currentCycle ; }
Returns status of required session id regeneration .
29,450
public function regenerate ( $ flush = false ) { $ status = session_regenerate_id ( $ flush ) ; $ this -> setId ( session_id ( ) ) ; if ( $ flush ) { $ lifetime = ( time ( ) - $ this -> getLifetime ( ) ) ; } else { $ lifetime = $ this -> getLifetime ( ) ; } return $ status ; }
Regenerates the whole session .
29,451
public function findClassFile ( $ class , $ baseDir = null ) { $ baseDir = is_null ( $ baseDir ) ? getcwd ( ) : $ baseDir ; $ file = $ this -> mainLoader -> findFile ( $ class ) ; if ( is_file ( $ file ) ) { $ spl = PathUtil :: createSplFileInfo ( $ baseDir , $ file ) ; return $ spl ; } return false ; }
Find class file for class
29,452
private function initialize ( ) { if ( is_file ( $ file = getcwd ( ) . '/vendor/autoload.php' ) ) { include_once $ file ; } $ functions = spl_autoload_functions ( ) ; foreach ( $ functions as $ loader ) { if ( is_array ( $ loader ) ) { $ ob = $ loader [ 0 ] ; if ( is_object ( $ ob ) ) { $ this -> addAutoloader ( $ ob ) ; } } } }
Initialize all registered loaders
29,453
public function addSummary ( $ value , $ type = 'text' ) { $ element = $ this -> addChild ( 'atom:summary' , 'summary' ) ; $ element -> setContent ( $ value , $ type ) ; return $ element ; }
Add summary .
29,454
public function setSession ( SessionInterface $ session ) { if ( ! is_object ( $ session ) || $ this -> session !== null ) { return false ; } $ this -> session = $ session ; return true ; }
Adds a session object to the request
29,455
public function getHeader ( $ key ) { if ( ! isset ( $ this -> headers [ $ key ] ) ) { return false ; } return $ this -> headers [ $ key ] ; }
Returns the value for the given header key
29,456
public function removeArgument ( $ argument ) { if ( true === isset ( $ this -> arguments [ $ argument ] ) ) { unset ( $ this -> arguments [ $ argument ] ) ; } }
Remover for argument .
29,457
public function get ( $ action , array $ query = [ ] ) { $ query [ 'action' ] = $ action ; $ query [ 'username' ] = $ this -> username ; $ query [ 'password' ] = $ this -> password ; $ endpoint = 'json' ; if ( ! empty ( $ query ) ) { $ endpoint .= '?' . http_build_query ( $ query ) ; } $ request = $ this -> createRequest ( 'GET' , $ endpoint ) ; return $ this -> sendRequest ( $ request ) ; }
Make an HTTP GET request .
29,458
public function sendMessage ( $ to , $ message , $ from = null , $ reportMask = 19 , $ reportUrl = null , $ charset = null , $ dataCoding = null , $ messageClass = - 1 , $ autoDetectEncoding = false ) { $ data = [ 'to' => $ to , 'text' => $ message , 'from' => $ from , 'report_mask' => $ reportMask , 'report_url' => $ reportUrl , 'charset' => $ charset , 'data_coding' => $ dataCoding , 'message_class' => $ messageClass , 'auto_detect_encoding' => $ autoDetectEncoding ? 1 : 0 , ] ; return $ this -> get ( 'message_send' , $ data ) ; }
Send an SMS .
29,459
public function deleted ( Member $ member ) { $ user = $ member -> user ; if ( $ user -> members -> count ( ) === 0 ) { $ user -> forceDelete ( ) ; } }
Listen to the Member delete event .
29,460
public function listAction ( ) { if ( false === $ this -> get ( 'security.context' ) -> isGranted ( 'ROLE_SUPER_ADMIN' ) ) { throw new AccessDeniedException ( ) ; } $ datatable = $ this -> get ( 'olix_security.datatable.user' ) ; $ datatable -> buildDatatable ( array ( 'entity' => $ this -> container -> getParameter ( 'fos_user.model.user.class' ) , 'delay' => $ this -> container -> getParameter ( 'olix.security.activity.delay' ) , ) ) ; $ form = $ this -> createFormBuilder ( ) -> getForm ( ) ; return $ this -> container -> get ( 'olix.admin' ) -> render ( 'OlixSecurityBundle:UserManager:list.html.twig' , 'olix_security_users' , array ( 'form' => $ form -> createView ( ) , 'datatable' => $ datatable , ) ) ; }
Page de listing des utilisateurs
29,461
public function getResultsAction ( ) { $ datatable = $ this -> get ( 'olix_security.datatable.user' ) ; $ datatable -> buildDatatable ( array ( 'entity' => $ this -> container -> getParameter ( 'fos_user.model.user.class' ) , 'delay' => $ this -> container -> getParameter ( 'olix.security.activity.delay' ) , ) ) ; $ query = $ this -> get ( 'sg_datatables.query' ) -> getQueryFrom ( $ datatable ) ; return $ query -> getResponse ( ) ; }
Retourne les utilisateurs en mode AJAX
29,462
protected function useKey ( string $ key , $ value = null ) : string { if ( $ value !== null && $ this -> isValidType ( $ value ) === false ) { throw new \ InvalidArgumentException ( $ this -> messageInvalidValue ) ; } return ( ( $ value === null ) ? $ key : $ value -> getName ( ) ) ; }
Ajusta o nome das chaves dos cookies para que seja sempre o mesmo nome definido para o cookie passado .
29,463
public function indexBy ( array $ data , $ key ) { $ newData = [ ] ; foreach ( $ data as $ row ) { $ newData [ $ row [ $ key ] ] = $ row ; } return $ newData ; }
Specifies a field to be the key of the array
29,464
public function orderBy ( array $ array , $ key = 'sort' , $ type = SORT_DESC ) { $ array2 = [ ] ; foreach ( $ array as $ k => $ v ) { $ array2 [ $ k ] = $ v [ $ key ] ; } array_multisort ( $ array2 , $ type , $ array ) ; return $ array ; }
Sort multi - dimensional array
29,465
public function run ( $ args ) { $ args = $ this -> parseArgs ( $ args ) ; foreach ( $ this -> options as $ argument => $ attribute ) { $ this -> { $ attribute } = in_array ( $ argument , $ args ) ; if ( $ this -> { $ attribute } ) { $ args = array_values ( array_diff ( $ args , [ $ argument ] ) ) ; } } if ( ! isset ( $ args [ 0 ] ) || ! $ args [ 0 ] ) { return $ this -> initPath ( $ this -> cwd ) ; } $ projectName = $ args [ 0 ] ; if ( ! $ this -> existsProjectName ( $ projectName ) ) { return "> Producer: Project '{$this->projectsDir}/{$projectName}' not found.\n" ; } return $ this -> initPath ( $ this -> getProjectDir ( $ projectName ) ) ; }
Run init command .
29,466
private function initComposerJson ( $ path , $ repositoryUrl , $ packageName ) { $ json = [ ] ; $ composerJson = $ path . '/composer.json' ; if ( file_exists ( $ composerJson ) ) { $ json = json_decode ( file_get_contents ( $ composerJson ) , true ) ; } if ( ! isset ( $ json [ 'name' ] ) ) { $ json [ 'name' ] = $ packageName ; } if ( ! isset ( $ json [ 'version' ] ) ) { $ json [ 'version' ] = '0.0.1' ; } if ( ! isset ( $ json [ 'repositories' ] ) ) { $ json [ 'repositories' ] = [ [ 'type' => 'git' , 'url' => $ repositoryUrl ] ] ; } else { $ hasRepositoryUrl = false ; foreach ( $ json [ 'repositories' ] as $ item ) { if ( $ item [ 'type' ] == 'git' ) { $ hasRepositoryUrl = true ; break ; } } if ( ! $ hasRepositoryUrl ) { $ json [ 'repositories' ] [ ] = [ 'type' => 'git' , 'url' => $ repositoryUrl ] ; } } $ size = file_put_contents ( $ composerJson , json_encode ( $ json , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) ) ; if ( ! $ size ) { $ this -> error ( "Error to write file '{$composerJson}'." ) ; } }
Initialize composer . json file .
29,467
private function initPackageClassPhp ( $ path , $ packageName ) { $ class = $ this -> getClass ( $ packageName ) ; $ namespace = $ this -> getNamespace ( $ packageName ) ; $ file = $ path . '/src/' . $ class . '.php' ; if ( file_exists ( $ file ) ) { return ; } $ code = file_get_contents ( __DIR__ . '/../../tpl/PackageClass.php.txt' ) ; $ code = str_replace ( [ '%%CLASS%%' , '%%NAMESPACE%%' ] , [ $ class , $ namespace ] , $ code ) ; if ( ! is_dir ( $ path . '/src' ) ) { mkdir ( $ path . '/src' ) ; } file_put_contents ( $ file , $ code ) ; }
Initialize sample Class .
29,468
private function getClass ( $ repo ) { $ class = S :: create ( str_replace ( [ '.' ] , [ '-' ] , basename ( $ repo , '.git' ) ) ) -> camelize ( ) ; return ucfirst ( trim ( $ class ) ) ; }
Get class name by repository url .
29,469
public static function send ( $ data , $ useMasterKey = false ) { if ( isset ( $ data [ 'expiration_time' ] ) && isset ( $ data [ 'expiration_interval' ] ) ) { throw new \ Exception ( 'Both expiration_time and expiration_interval can\'t be set.' ) ; } if ( isset ( $ data [ 'where' ] ) ) { if ( $ data [ 'where' ] instanceof AVQuery ) { $ data [ 'where' ] = $ data [ 'where' ] -> _getOptions ( ) [ 'where' ] ; } else { throw new \ Exception ( 'Where parameter for Avos Push must be of type AVQuery' ) ; } } if ( isset ( $ data [ 'push_time' ] ) ) { $ data [ 'push_time' ] = AVClient :: getLocalPushDateFormat ( $ data [ 'push_time' ] ) ; } if ( isset ( $ data [ 'expiration_time' ] ) ) { $ data [ 'expiration_time' ] = AVClient :: _encode ( $ data [ 'expiration_time' ] , false ) [ 'iso' ] ; } return AVClient :: _request ( 'POST' , '/push' , null , json_encode ( $ data ) , $ useMasterKey ) ; }
Sends a push notification .
29,470
public function instance ( $ model , $ altClass = null , $ fail = false ) { if ( is_null ( $ altClass ) ) $ class = get_class ( ) ; else $ class = ( string ) $ class ; if ( is_a ( $ model , $ class ) ) return $ model ; elseif ( is_int ( $ model ) ) return ( $ fail ) ? $ this -> findOrFail ( $ model ) : $ this -> find ( $ model ) ; return null ; }
get instance of a model
29,471
public function guarded ( $ guard = null ) { if ( ! $ this -> isAuthGuarded ( ) ) { if ( is_null ( $ guard ) ) $ guard = $ this -> guard ; $ this -> user = $ this -> users ( ) -> findOrFail ( Auth :: guard ( $ guard ) -> user ( ) -> id ) ; } return $ this ; }
Test guarding .
29,472
public function isType ( $ tokenTypes ) { if ( is_array ( $ tokenTypes ) ) { return in_array ( $ this -> getType ( ) , $ tokenTypes ) ; } return $ this -> getType ( ) === $ tokenTypes ; }
Compares token types .
29,473
protected function getTypeName ( ) { $ result = $ this -> type ; foreach ( get_defined_constants ( ) as $ name => $ value ) { if ( substr ( $ name , 0 , 2 ) === 'T_' && $ value === $ this -> type ) { $ result = $ name ; break ; } } return $ result ; }
Returns name of the token type . Shouldn t be used outside debugging purposes .
29,474
public static function getKeywords ( ) { static $ keywords = null ; if ( $ keywords === null ) { $ keywords = [ ] ; $ keywordsStrings = [ 'T_ABSTRACT' , 'T_ARRAY' , 'T_AS' , 'T_BREAK' , 'T_CALLABLE' , 'T_CASE' , 'T_CATCH' , 'T_CLASS' , 'T_CLONE' , 'T_CONST' , 'T_CONTINUE' , 'T_DECLARE' , 'T_DEFAULT' , 'T_DO' , 'T_ECHO' , 'T_ELSE' , 'T_ELSEIF' , 'T_EMPTY' , 'T_ENDDECLARE' , 'T_ENDFOR' , 'T_ENDFOREACH' , 'T_ENDIF' , 'T_ENDSWITCH' , 'T_ENDWHILE' , 'T_EVAL' , 'T_EXIT' , 'T_EXTENDS' , 'T_FINAL' , 'T_FINALLY' , 'T_FOR' , 'T_FOREACH' , 'T_FUNCTION' , 'T_GLOBAL' , 'T_GOTO' , 'T_HALT_COMPILER' , 'T_IF' , 'T_IMPLEMENTS' , 'T_INCLUDE' , 'T_INCLUDE_ONCE' , 'T_INSTANCEOF' , 'T_INSTEADOF' , 'T_INTERFACE' , 'T_ISSET' , 'T_LIST' , 'T_LOGICAL_AND' , 'T_LOGICAL_OR' , 'T_LOGICAL_XOR' , 'T_NAMESPACE' , 'T_NEW' , 'T_PRINT' , 'T_PRIVATE' , 'T_PROTECTED' , 'T_PUBLIC' , 'T_REQUIRE' , 'T_REQUIRE_ONCE' , 'T_RETURN' , 'T_STATIC' , 'T_SWITCH' , 'T_THROW' , 'T_TRAIT' , 'T_TRY' , 'T_UNSET' , 'T_USE' , 'T_VAR' , 'T_WHILE' , 'T_YIELD' , ] ; foreach ( $ keywordsStrings as $ keywordName ) { if ( defined ( $ keywordName ) ) { $ keyword = constant ( $ keywordName ) ; $ keywords [ $ keyword ] = $ keyword ; } } } return $ keywords ; }
Generate keywords array contains all keywords that exists in used PHP version .
29,475
final public function transPreventCommit ( bool $ preventCommit = null ) : bool { if ( null === $ preventCommit ) { return $ this -> preventCommit ; } $ previous = $ this -> preventCommit ; $ this -> preventCommit = $ preventCommit ; return $ previous ; }
This function prevent the upper transaction to commit In case of commit the transCommitMehod will trigger an error and return without commit
29,476
final public function sqlTable ( string $ tableName , string $ asTable = '' ) : string { return $ this -> sqlTableEscape ( $ this -> settings -> get ( 'prefix' , '' ) . $ tableName , $ asTable ) ; }
Escapes a table name including its prefix and optionally renames it . This is the same method as sqlTableEscape but using the table prefix from settings . Optionaly renames it as an alias .
29,477
final public function sqlField ( string $ fieldName , string $ asFieldName = '' ) : string { return $ fieldName . ( ( '' !== $ asFieldName ) ? ' AS ' . $ this -> sqlFieldEscape ( $ asFieldName ) : '' ) ; }
Return a field name Optionaly renames it as an alias . This function do not escape the field name .
29,478
final public function sqlQuoteIn ( array $ values , string $ commonType = CommonTypes :: TTEXT , bool $ includeNull = false ) { if ( 0 === count ( $ values ) ) { throw new \ RuntimeException ( 'The array of values passed to DBAL::sqlQuoteIn is empty' ) ; } return '' . '(' . implode ( ', ' , array_map ( function ( $ value ) use ( $ commonType , $ includeNull ) { return $ this -> sqlQuote ( $ value , $ commonType , $ includeNull ) ; } , array_unique ( $ values ) ) ) . ')' ; }
Parses values to secure SQL for IN operator
29,479
final public function sqlIn ( string $ field , array $ values , string $ commonType = CommonTypes :: TTEXT , bool $ positive = true , bool $ includeNull = false ) : string { if ( ! $ positive ) { trigger_error ( __METHOD__ . ' with argument $positive = false is deprecated, use DBAL::sqlNotIn' , E_USER_NOTICE ) ; return $ this -> sqlNotIn ( $ field , $ values , $ commonType , $ includeNull ) ; } if ( 0 === count ( $ values ) ) { return '0 = 1' ; } return $ field . ' IN ' . $ this -> sqlQuoteIn ( $ values , $ commonType , $ includeNull ) ; }
Return a comparison condition using IN operator If the array of values is empty then create an always false condition 0 = 1
29,480
final public function sqlNotIn ( string $ field , array $ values , string $ commonType = CommonTypes :: TTEXT , bool $ includeNull = false ) : string { if ( 0 === count ( $ values ) ) { return '1 = 1' ; } return $ field . ' NOT IN ' . $ this -> sqlQuoteIn ( $ values , $ commonType , $ includeNull ) ; }
Return a NEGATIVE comparison condition using IN operator If the array of values is empty then create an always true condition 1 = 1
29,481
final public function sqlIsNull ( string $ field , bool $ positive = true ) : string { if ( ! $ positive ) { trigger_error ( __METHOD__ . ' with argument $positive = false is deprecated, use DBAL::sqlIsNotNull' , E_USER_NOTICE ) ; return $ this -> sqlIsNotNull ( $ field ) ; } return $ field . ' IS NULL' ; }
Return a comparison condition against null
29,482
final public function sqlBetweenQuote ( string $ field , $ lowerBound , $ upperBound , string $ commonType = CommonTypes :: TTEXT ) : string { return $ field . ' BETWEEN ' . $ this -> sqlQuote ( $ lowerBound , $ commonType ) . ' AND ' . $ this -> sqlQuote ( $ upperBound , $ commonType ) . ';' ; }
Return a condition using between operator quoting lower and upper bounds
29,483
final public function execute ( string $ query , string $ exceptionMessage = '' ) { $ return = $ this -> queryAffectedRows ( $ query ) ; if ( false === $ return ) { if ( '' !== $ exceptionMessage ) { $ previous = $ this -> getLastErrorMessage ( ) ? new \ RuntimeException ( $ this -> getLastErrorMessage ( ) ) : null ; throw new QueryException ( $ exceptionMessage , $ query , 0 , $ previous ) ; } return false ; } $ this -> logger -> info ( "-- AffectedRows: $return" ) ; return $ return ; }
Executes a query and return the affected rows
29,484
final public function queryValues ( string $ query , array $ overrideTypes = [ ] ) { $ recordset = $ this -> queryRecordset ( $ query , '' , [ ] , $ overrideTypes ) ; if ( false === $ recordset ) { return false ; } if ( $ recordset -> eof ( ) ) { return false ; } return $ recordset -> values ; }
Get the first row of a query the values are in common types
29,485
final public function queryArray ( string $ query ) { $ result = $ this -> queryResult ( $ query ) ; if ( false === $ result ) { return false ; } $ return = [ ] ; while ( false !== $ row = $ result -> fetchRow ( ) ) { $ return [ ] = $ row ; } return $ return ; }
Get an array of rows of a query
29,486
final public function queryArrayValues ( string $ query , array $ overrideTypes = [ ] ) { $ recordset = $ this -> queryRecordset ( $ query , '' , [ ] , $ overrideTypes ) ; if ( false === $ recordset ) { return false ; } $ return = [ ] ; while ( ! $ recordset -> eof ( ) ) { $ return [ ] = $ recordset -> values ; $ recordset -> moveNext ( ) ; } return $ return ; }
Get an array of rows of a query the values are in common types
29,487
final public function queryArrayKey ( string $ query , string $ keyField , string $ keyPrefix = '' ) { $ result = $ this -> queryResult ( $ query ) ; if ( false === $ result ) { return false ; } $ return = [ ] ; while ( $ row = $ result -> fetchRow ( ) ) { if ( ! array_key_exists ( $ keyField , $ row ) ) { return false ; } $ return [ $ keyPrefix . $ row [ $ keyField ] ] = $ row ; } return $ return ; }
Get an array of rows of a query It uses the keyField as index of the array
29,488
final public function queryPairs ( string $ query , string $ keyField , string $ valueField , string $ keyPrefix = '' , $ default = false ) : array { $ array = $ this -> queryArray ( $ query ) ? : [ ] ; $ return = [ ] ; foreach ( $ array as $ row ) { $ return [ $ keyPrefix . ( $ row [ $ keyField ] ?? '' ) ] = $ row [ $ valueField ] ?? $ default ; } return $ return ; }
Return a one dimension array with keys and values defined by keyField and valueField The resulting array keys can have a prefix defined by keyPrefix If two keys collapse then the last value will be used Always return an array even if it fails
29,489
final public function queryArrayOne ( string $ query , string $ field = '' ) { $ result = $ this -> queryResult ( $ query ) ; if ( false === $ result ) { return false ; } $ return = [ ] ; $ verifiedFieldName = false ; while ( $ row = $ result -> fetchRow ( ) ) { if ( '' === $ field ) { $ keys = array_keys ( $ row ) ; $ field = $ keys [ 0 ] ; $ verifiedFieldName = true ; } if ( ! $ verifiedFieldName ) { if ( ! array_key_exists ( $ field , $ row ) ) { return false ; } $ verifiedFieldName = true ; } $ return [ ] = $ row [ $ field ] ?? null ; } return $ return ; }
Return one dimensional array with the values of one column of the query If the field is not set then the function will take the first column
29,490
final public function queryOnString ( string $ query , string $ default = '' , string $ separator = ', ' ) : string { $ array = $ this -> queryArrayOne ( $ query ) ; if ( false === $ array ) { return $ default ; } return implode ( $ separator , $ array ) ; }
Return the result of the query as a imploded string with all the values of the first column
29,491
final public function queryRecordset ( string $ query , string $ overrideEntity = '' , array $ overrideKeys = [ ] , array $ overrideTypes = [ ] ) { try { $ recordset = $ this -> createRecordset ( $ query , $ overrideEntity , $ overrideKeys , $ overrideTypes ) ; } catch ( \ Throwable $ exception ) { $ this -> logger -> error ( "DBAL::queryRecordset failure running $query" ) ; return false ; } return $ recordset ; }
Returns a Recordset Object from the query false if error
29,492
final public function createRecordset ( string $ query , string $ overrideEntity = '' , array $ overrideKeys = [ ] , array $ overrideTypes = [ ] ) : Recordset { try { $ recordset = new Recordset ( $ this ) ; $ recordset -> query ( $ query , $ overrideEntity , $ overrideKeys , $ overrideTypes ) ; } catch ( \ Throwable $ exception ) { throw new QueryException ( 'Unable to create a valid Recordset' , $ query , 0 , $ exception ) ; } return $ recordset ; }
This is an strict mode of queryRecordset but throws an exception instead of return FALSE
29,493
final public function queryPager ( string $ querySelect , string $ queryCount = '' , int $ page = 1 , int $ recordsPerPage = 20 ) { try { return $ this -> createPager ( $ querySelect , $ queryCount , $ page , $ recordsPerPage ) ; } catch ( \ Throwable $ exception ) { $ this -> logger -> error ( "DBAL::queryPager failure running $querySelect" ) ; return false ; } }
Get a Pager Object from the query
29,494
final public function createPager ( string $ querySelect , string $ queryCount = '' , int $ page = 1 , int $ recordsPerPage = 20 ) : Pager { $ previous = null ; try { $ pager = new Pager ( $ this , $ querySelect , $ queryCount ) ; $ pager -> setPageSize ( $ recordsPerPage ) ; $ success = ( $ page == - 1 ) ? $ pager -> queryAll ( ) : $ pager -> queryPage ( $ page ) ; if ( ! $ success ) { $ pager = false ; } } catch ( \ Throwable $ exception ) { $ previous = $ exception ; $ pager = false ; } if ( ! ( $ pager instanceof Pager ) ) { throw new QueryException ( 'Unable to create a valid Pager' , $ querySelect , 0 , $ previous ) ; } return $ pager ; }
This is an strict mode of queryPager but throws an exception instead of return FALSE
29,495
final public function createQueryException ( string $ query , \ Throwable $ previous = null ) : QueryException { return new QueryException ( $ this -> getLastMessage ( ) ? : 'Database error' , $ query , 0 , $ previous ) ; }
Creates a QueryException with the last message if no last message exists then uses Database error
29,496
static function RedirectRelative ( $ target , $ noExit = false ) { session_write_close ( ) ; $ dirName = dirname ( $ _SERVER [ "PHP_SELF" ] ) ; if ( $ dirName == "/" ) $ dirName = "" ; header ( "Location: " . "http://" . $ _SERVER [ "HTTP_HOST" ] . $ dirName . "/" . $ target ) ; if ( ! $ noExit ) { exit ( ) ; } }
Redirects to a target whose path is relatively to the currently running php script
29,497
static function Redirect ( $ target , $ redirectHeader = "" , $ noExit = false ) { session_write_close ( ) ; if ( $ redirectHeader ) { header ( $ redirectHeader ) ; } header ( "Location: " . $ target ) ; if ( ! $ noExit ) { exit ( ) ; } }
Sends the header string if given and redirects to the target
29,498
public function checkDATA ( ) { if ( ! defined ( DATA ) ) define ( DATA , __DIR__ . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR ) ; if ( ! is_dir ( DATA ) ) mkdir ( DATA , 0777 , true ) ; return $ this ; }
Checks if the DATA constant is declared and declares it if not
29,499
public function getIndexes ( $ columnName = null ) { if ( ! $ this -> indexes ) { $ this -> indexes = array ( ) ; } return ( $ columnName ) ? $ this -> indexes [ $ columnName ] : $ this -> indexes ; }
Fetches the indexes