idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
5,300
private static function toCamelCase ( string $ text ) : string { if ( strpos ( $ text , '_' ) !== false ) { $ text = str_replace ( ' ' , '' , ucwords ( str_replace ( '_' , ' ' , $ text ) ) ) ; } $ text [ 0 ] = strtolower ( $ text [ 0 ] ) ; return $ text ; }
Changes string with underscores to camelCase string . First letter is low .
5,301
public function onKernelRequest ( GetResponseEvent $ event ) { $ currentLocale = $ this -> getCurrentLocale ( ) ; $ requestedLocale = $ this -> getRequestedLocale ( ) ; if ( $ requestedLocale && $ currentLocale != $ requestedLocale ) { $ request = $ event -> getRequest ( ) ; if ( ! method_exists ( $ request , 'setLocal...
Binds the default domain to the combined translations on Kernel Request
5,302
public function setAccountKey ( string $ publicKey , string $ confirm ) { $ this -> publicKey = $ publicKey ; $ this -> confirm = $ confirm ; }
Sets key of account .
5,303
protected function getClientOptions ( ) { $ counter = count ( $ this -> allModels ) ? max ( array_keys ( $ this -> allModels ) ) + 1 : 0 ; $ clientOptions = $ this -> clientOptions ; $ clientOptions [ 'counter' ] = $ counter ; if ( empty ( $ clientOptions [ 'itemSelector' ] ) ) { throw new InvalidConfigException ( 'Val...
Get client options
5,304
public function checkMandatoryKey ( ) { foreach ( $ this -> mandatoryKeys as $ key ) { if ( ! array_key_exists ( $ key , $ this ) ) { return $ key ; } } return true ; }
Return true if all mandatory keys are defined or the missing key name
5,305
protected function checkJsonObject ( \ SwaggerValidator \ Common \ Context $ context , & $ jsonData ) { if ( ! is_object ( $ jsonData ) ) { $ context -> throwException ( 'Mismatching type of JSON Data received' , get_class ( $ this ) . '::' . __METHOD__ , __LINE__ ) ; } if ( ! ( $ jsonData instanceof \ stdClass ) ) { $...
Check that entry JsonData is an object of stdClass
5,306
protected function checkJsonObjectOrArray ( \ SwaggerValidator \ Common \ Context $ context , & $ jsonData ) { if ( is_object ( $ jsonData ) && ! ( $ jsonData instanceof \ stdClass ) ) { $ context -> throwException ( 'Mismatching type of JSON Data received' , get_class ( $ this ) . '::' . __METHOD__ , __LINE__ ) ; } el...
Check that entry JsonData is an object of stdClass or an array
5,307
public function reveal ( ) { $ delegate = $ this -> prophecy -> reveal ( ) ; $ builder = new MockBuilder ( ) ; $ builder -> setNamespace ( $ this -> namespace ) -> setName ( $ this -> functionName ) -> setFunction ( [ $ delegate , MockDelegateFunctionBuilder :: METHOD ] ) ; $ mock = $ builder -> build ( ) ; $ mock -> e...
Reveals the function prophecy .
5,308
public function renderInputCell ( $ model , $ key , $ index ) { $ form = $ this -> grid -> form ; $ items = $ this -> items ; if ( $ this -> widget !== null ) { if ( is_array ( $ this -> widget ) ) { list ( $ widget , $ options ) = $ this -> widget ; if ( $ options instanceof \ Closure ) { $ options = call_user_func ( ...
Render input cell
5,309
protected function findFilesInFolder ( $ dir , $ extension ) { $ templates = array ( ) ; if ( is_dir ( $ dir ) ) { $ finder = new Finder ( ) ; foreach ( $ finder -> files ( ) -> followLinks ( ) -> in ( $ dir ) -> exclude ( 'cache' ) -> name ( '*.' . $ extension ) as $ file ) { $ templates [ ] = $ this -> relative ( $ f...
Search for files with specific extension
5,310
private function relativePath ( $ from , $ to , $ ps = DIRECTORY_SEPARATOR ) { $ from = realpath ( $ from ) ; $ to = realpath ( $ to ) ; $ equalOffset = 0 ; $ minLength = min ( strlen ( $ from ) , strlen ( $ to ) ) ; while ( $ equalOffset < $ minLength && $ from [ $ equalOffset ] == $ to [ $ equalOffset ] ) { $ equalOf...
Get relative path from file to directory
5,311
protected function initializeFromTemplate ( $ template , $ languages ) { $ results = array ( ) ; $ target = dirname ( $ template ) ; if ( ! file_exists ( $ template ) ) { throw new ResourceNotFoundException ( "Template not found in: $template\n\nRun 'app/console gettext:bundle:extract' first." ) ; } $ results [ $ this ...
Initialize . po file from template
5,312
protected function compile ( $ file , $ path ) { $ results = array ( ) ; if ( file_exists ( "$path.tmp" ) ) { unlink ( "$path.tmp" ) ; } $ options = implode ( ' ' , array ( '--check' , "-o $path.tmp" , $ file , ) ) ; $ process = new Process ( 'msgfmt ' . $ options ) ; $ process -> run ( ) ; $ output = $ process -> getO...
Compile message catalog to binary format
5,313
public function regenerateId ( int $ interval , string $ key = 'session-id-expires' ) : self { $ this -> regenerateIdInterval = $ interval ; $ this -> sessionIdExpiryKey = $ key ; return $ this ; }
Set the session id regenerate interval and id expiry key name .
5,314
private static function runIdRegeneration ( int $ interval = null , string $ key = null ) { if ( empty ( $ interval ) ) { return ; } $ expiry = time ( ) + $ interval ; if ( ! isset ( $ _SESSION [ $ key ] ) ) { $ _SESSION [ $ key ] = $ expiry ; } if ( $ _SESSION [ $ key ] < time ( ) || $ _SESSION [ $ key ] > $ expiry ) ...
Regenerate the session id if it s needed
5,315
public function filter ( int $ value ) : string { if ( $ value < 0 ) { throw new Exception ( sprintf ( 'Invalid integer: %d' , $ value ) , Exception :: INVALID_INTEGER ) ; } $ tokens = $ this -> getGrammar ( ) -> getTokens ( ) ; $ values = array_reverse ( $ this -> getGrammar ( ) -> getValuesWithModifiers ( ) , true ) ...
Filter Integer to Roman Number
5,316
public function warnIf ( $ condition , $ message = '' ) { $ message = ( strlen ( $ message ) ) ? $ message : 'Unknown Reason' ; if ( true === $ condition ) { $ this -> outputWriter -> write ( ' <warning>Warning during ' . $ this -> version -> getExecutionState ( ) . ': ' . $ message . '</warning>' ) ; } }
Print a warning message if the condition evalutes to TRUE .
5,317
public function abortIf ( $ condition , $ message = '' ) { $ message = ( strlen ( $ message ) ) ? $ message : 'Unknown Reason' ; if ( true === $ condition ) { throw new AbortException ( $ message ) ; } }
Abort the migration if the condition evalutes to TRUE .
5,318
public function constructUsing ( $ objectCreator ) { if ( $ objectCreator instanceof \ Closure ) { $ objectCreator = new ClosureObjectCreator ( $ objectCreator ) ; } if ( ! $ objectCreator instanceof ObjectCreatorInterface ) { throw new PapperConfigurationException ( 'Argument objectCreator must be closure or instance ...
Supply a custom instantiation function for the destination type
5,319
public function forMember ( $ name , $ memberOptions ) { $ propertyMap = $ this -> typeMap -> getPropertyMap ( $ name ) ; if ( $ propertyMap === null ) { throw new PapperConfigurationException ( sprintf ( 'Unable to find destination member %s on type %s' , $ name , $ this -> typeMap -> getDestinationType ( ) ) ) ; } $ ...
Customize configuration for individual member
5,320
public function forDynamicMember ( $ name , $ memberOptions = null ) { $ propertyMap = $ this -> typeMap -> getPropertyMap ( $ name ) ; if ( $ propertyMap !== null ) { throw new PapperConfigurationException ( sprintf ( 'Unable to create dynamic destination member %s on type %s because it already exists in type' , $ nam...
Create configuration for individual dynamic member
5,321
protected function addTokenValue ( string $ token , string $ modifier = null , int $ quantity = 1 ) : self { $ tokens = array_flip ( $ this -> getGrammar ( ) -> getTokens ( ) ) ; $ values = $ this -> getGrammar ( ) -> getValuesWithModifiers ( ) ; $ elements = [ ] ; if ( isset ( $ modifier ) ) { $ elements [ ] = $ token...
Add Token Value
5,322
private function doTransitionFromY ( ) : self { if ( $ this -> getToken ( ) !== '$' ) { throw ( new Exception ( 'Invalid Roman' , Exception :: INVALID_ROMAN ) ) -> setPosition ( $ this -> getPosition ( ) ) -> setToken ( $ this -> getToken ( ) ) ; } $ this -> setState ( self :: STATE_Z ) ; return $ this ; }
Do Transition from Y
5,323
private function doTransitionFromG ( ) : self { if ( $ this -> getToken ( ) === Grammar :: T_N ) { $ this -> setState ( self :: STATE_Y ) -> addPosition ( 1 ) ; return $ this ; } if ( $ this -> getToken ( ) === Grammar :: T_M ) { $ this -> setState ( self :: STATE_G ) -> addPosition ( 1 ) -> addTokenValue ( Grammar :: ...
Do Transition from G
5,324
private function doTransitionFromF ( ) : self { if ( $ this -> getToken ( ) === Grammar :: T_D ) { $ this -> setState ( self :: STATE_E ) -> addPosition ( 1 ) -> addTokenValue ( Grammar :: T_D ) ; return $ this ; } if ( $ this -> getToken ( ) === Grammar :: T_C && $ this -> hasToken ( 1 ) && $ this -> getToken ( 1 ) ==...
Do Transition from F
5,325
private function doTransitionFromE ( ) : self { if ( $ this -> getToken ( ) === Grammar :: T_C ) { if ( $ this -> hasToken ( 1 ) && $ this -> getToken ( 1 ) === Grammar :: T_C ) { if ( $ this -> hasToken ( 2 ) && $ this -> getToken ( 2 ) === Grammar :: T_C ) { $ this -> setState ( self :: STATE_D ) -> addPosition ( 3 )...
Do Transition from E
5,326
private function doTransitionFromD ( ) : self { if ( $ this -> getToken ( ) === Grammar :: T_L ) { $ this -> setState ( self :: STATE_C ) -> addPosition ( 1 ) -> addTokenValue ( Grammar :: T_L ) ; return $ this ; } if ( $ this -> getToken ( ) === Grammar :: T_X && $ this -> hasToken ( 1 ) && $ this -> getToken ( 1 ) ==...
Do Transition from D
5,327
private function doTransitionFromC ( ) : self { if ( $ this -> getToken ( ) === Grammar :: T_X ) { if ( $ this -> hasToken ( 1 ) && $ this -> getToken ( 1 ) === Grammar :: T_X ) { if ( $ this -> hasToken ( 2 ) && $ this -> getToken ( 2 ) === Grammar :: T_X ) { $ this -> setState ( self :: STATE_B ) -> addPosition ( 3 )...
Do Transition from C
5,328
private function doTransitionFromB ( ) : self { if ( $ this -> getToken ( ) === Grammar :: T_V ) { $ this -> setState ( self :: STATE_A ) -> addPosition ( 1 ) -> addTokenValue ( Grammar :: T_V ) ; return $ this ; } if ( $ this -> getToken ( ) === Grammar :: T_I && $ this -> hasToken ( 1 ) && $ this -> getToken ( 1 ) ==...
Do Transition from B
5,329
private function doTransitionFromA ( ) : self { if ( $ this -> getToken ( ) === Grammar :: T_I ) { if ( $ this -> hasToken ( 1 ) && $ this -> getToken ( 1 ) === Grammar :: T_I ) { if ( $ this -> hasToken ( 2 ) && $ this -> getToken ( 2 ) === Grammar :: T_I ) { $ this -> setState ( self :: STATE_Y ) -> addPosition ( 3 )...
Do Transition From A
5,330
protected function getDirectoryRelativeToFile ( string $ configFile , ? string $ directory = null ) : ? string { if ( ! $ directory ) { return null ; } $ path = realpath ( dirname ( $ configFile ) . '/' . $ directory ) ; if ( false !== $ path ) { return $ path ; } return $ directory ; }
Get the path to the directory relative to the config file .
5,331
public function execute ( MappingContext $ context ) { $ typeMap = $ this -> config -> findTypeMap ( $ context -> getSourceType ( ) , $ context -> getDestinationType ( ) ) ; try { $ typeMap -> validate ( ) ; $ mapFunc = $ typeMap -> getMapFunc ( ) ; $ destination = is_array ( $ context -> getSource ( ) ) ? $ this -> ma...
Execute a mapping using MappingContext
5,332
public function validate ( ) { $ errors = array ( ) ; foreach ( $ this -> config -> getAllTypeMaps ( ) as $ typeMap ) { try { $ typeMap -> validate ( ) ; } catch ( \ Exception $ e ) { $ errors [ ] = $ e -> getMessage ( ) ; } } if ( ! empty ( $ errors ) ) { throw new ValidationException ( implode ( "\n\n" , $ errors ) )...
Validates that every top level destination property is mapped to source property . If not a ConfigurationException is thrown detailing any missing mappings .
5,333
public function getValuesWithModifiers ( ) { $ values = array_map ( function ( $ value ) { return [ $ value ] ; } , array_flip ( $ this -> getValues ( ) ) ) ; $ valuesWithModifiers = $ values + $ this -> getModifiers ( ) ; ksort ( $ valuesWithModifiers ) ; return $ valuesWithModifiers ; }
Get Values with Modifiers
5,334
public function execute ( $ direction , $ replay = false ) { if ( 'down' === $ direction && $ replay ) { throw new AbortException ( 'Cannot run \'down\' and replay it. Use replay with \'up\'' ) ; } try { $ start = microtime ( true ) ; $ this -> state = self :: STATE_PRE ; $ this -> migration -> { 'pre' . ucfirst ( $ di...
Execute this migration version up or down .
5,335
protected function validateKey ( $ key ) { if ( ! is_string ( $ key ) || $ key === '' ) { throw new InvalidArgumentException ( 'Key should be a non empty string' ) ; } $ unsupportedMatched = preg_match ( '#[' . preg_quote ( $ this -> getReservedKeyCharacters ( ) ) . ']#' , $ key ) ; if ( $ unsupportedMatched > 0 ) { th...
Determines if the specified key is legal under PSR - 6 .
5,336
public function to ( $ destination , $ destinationType = null ) { $ this -> context -> setDestination ( $ destination , $ destinationType ) ; return $ this -> engine -> execute ( $ this -> context ) ; }
Execute a mapping to the existing destination object . If no Map exists then one is created .
5,337
public function toType ( $ destinationType ) { $ this -> context -> setDestination ( null , $ destinationType ) ; return $ this -> engine -> execute ( $ this -> context ) ; }
Execute a mapping to a new destination object . If no Map exists then one is created .
5,338
public function migrate ( $ to = null ) { if ( null === $ to ) { $ to = $ this -> configuration -> getLatestVersion ( ) ; } $ from = $ this -> configuration -> getCurrentVersion ( ) ; $ from = ( string ) $ from ; $ to = ( string ) $ to ; $ migrations = $ this -> configuration -> getMigrations ( ) ; if ( ! isset ( $ mig...
Run a migration to the current version or the given target version .
5,339
public static function registerTranslations ( ) { if ( ! isset ( Yii :: $ app -> i18n -> translations [ 'jcrop' ] ) && ! isset ( Yii :: $ app -> i18n -> translations [ 'jcrop/*' ] ) ) { Yii :: $ app -> i18n -> translations [ 'jcrop' ] = [ 'class' => 'yii\i18n\PhpMessageSource' , 'basePath' => '@developit/jcrop/messages...
Register widget translations .
5,340
protected function _markUnrelatedAsHidden ( & $ tree , array $ path , $ level = 0 ) { extract ( $ this -> _config ) ; $ siblingIsActive = false ; foreach ( $ tree as $ key => & $ subTree ) { if ( is_object ( $ subTree ) ) { $ subTree = $ subTree -> toArray ( ) ; } if ( ! isset ( $ subTree [ 'children' ] ) ) { throw new...
Mark unrelated records as hidden using hide = > 1 . In the callback or element you can then return early in this case .
5,341
public function filter ( string $ value ) : int { return $ this -> getParser ( ) -> parse ( $ this -> getLexer ( ) -> tokenize ( $ value ) ) ; }
Filter Roman Number to Integer
5,342
public static function formatVersion ( $ version ) { return sprintf ( '%s-%s-%s %s:%s:%s' , substr ( $ version , 0 , 4 ) , substr ( $ version , 4 , 2 ) , substr ( $ version , 6 , 2 ) , substr ( $ version , 8 , 2 ) , substr ( $ version , 10 , 2 ) , substr ( $ version , 12 , 2 ) ) ; }
Returns a timestamp version as a formatted date .
5,343
public function getAvailableVersions ( ) { $ availableVersions = [ ] ; foreach ( $ this -> migrations as $ migration ) { $ availableVersions [ ] = $ migration -> getVersion ( ) ; } return $ availableVersions ; }
Returns an array of available migration version numbers .
5,344
public function getMigratedVersions ( ) { $ this -> createMigrationCollection ( ) ; $ cursor = $ this -> getCollection ( ) -> find ( ) ; $ versions = [ ] ; foreach ( $ cursor as $ record ) { $ versions [ ] = $ record [ 'v' ] ; } return $ versions ; }
Returns all migrated versions from the versions collection in an array .
5,345
public function getMigratedTimestamp ( $ version ) : int { $ this -> createMigrationCollection ( ) ; $ cursor = $ this -> getCollection ( ) -> find ( [ 'v' => $ version ] ) ; if ( ! $ cursor -> count ( ) ) { throw new UnknownVersionException ( $ version ) ; } if ( $ cursor -> count ( ) > 1 ) { throw new \ DomainExcepti...
Returns the time a migration occurred .
5,346
public function registerMigration ( $ version , $ class ) { $ version = ( string ) $ version ; $ class = ( string ) $ class ; if ( isset ( $ this -> migrations [ $ version ] ) ) { $ message = sprintf ( 'Migration version %s already registered with class %s' , $ version , get_class ( $ this -> migrations [ $ version ] )...
Register a single migration version to be executed by a AbstractMigration class .
5,347
public function registerMigrations ( array $ migrations ) { $ versions = [ ] ; foreach ( $ migrations as $ version => $ class ) { $ versions [ ] = $ this -> registerMigration ( $ version , $ class ) ; } return $ versions ; }
Register an array of migrations . Each key of the array is the version and the value is the migration class name .
5,348
public function registerMigrationsFromDirectory ( $ path ) { $ path = realpath ( $ path ) ; $ path = rtrim ( $ path , '/' ) ; $ files = glob ( $ path . '/Version*.php' ) ; $ versions = [ ] ; if ( $ files ) { foreach ( $ files as $ file ) { require_once $ file ; $ info = pathinfo ( $ file ) ; $ version = substr ( $ info...
Register migrations from a given directory . Recursively finds all files with the pattern VersionYYYYMMDDHHMMSS . php as the filename and registers them as migrations .
5,349
public function getVersion ( $ version ) { if ( ! isset ( $ this -> migrations [ $ version ] ) ) { throw new UnknownVersionException ( $ version ) ; } return $ this -> migrations [ $ version ] ; }
Returns the Version instance for a given version in the format YYYYMMDDHHMMSS .
5,350
public function hasVersionMigrated ( Version $ version ) { $ this -> createMigrationCollection ( ) ; $ record = $ this -> getCollection ( ) -> findOne ( [ 'v' => $ version -> getVersion ( ) ] ) ; return null !== $ record ; }
Check if a version has been migrated or not yet .
5,351
public function createMigrationCollection ( ) { $ this -> validate ( ) ; if ( true !== $ this -> migrationCollectionCreated ) { $ collection = $ this -> getCollection ( ) ; $ collection -> ensureIndex ( [ 'v' => - 1 ] , [ 'name' => 'version' , 'unique' => true ] ) ; $ this -> migrationCollectionCreated = true ; } retur...
Create the migration collection to track migrations with .
5,352
public function getMigrationsToExecute ( $ direction , $ to ) { if ( 'down' === $ direction ) { if ( count ( $ this -> migrations ) ) { $ allVersions = array_reverse ( array_keys ( $ this -> migrations ) ) ; $ classes = array_reverse ( array_values ( $ this -> migrations ) ) ; $ allVersions = array_combine ( $ allVersi...
Returns the array of migrations to executed based on the given direction and target version number .
5,353
private function shouldExecuteMigration ( $ direction , Version $ version , $ to , $ migrated ) { if ( 'down' === $ direction ) { if ( ! in_array ( $ version -> getVersion ( ) , $ migrated ) ) { return false ; } return $ version -> getVersion ( ) > $ to ; } if ( 'up' === $ direction ) { if ( in_array ( $ version -> get...
Check if we should execute a migration for a given direction and target migration version .
5,354
public function validate ( ) { if ( ! $ this -> migrationsDatabaseName ) { $ message = 'Migrations Database Name must be configured in order to use AntiMattr migrations.' ; throw new ConfigurationValidationException ( $ message ) ; } if ( ! $ this -> migrationsNamespace ) { $ message = 'Migrations namespace must be con...
Validation that this instance has all the required properties configured .
5,355
public function store ( Request $ request ) { $ validator = Validator :: make ( $ request -> all ( ) , [ 'name' => 'required|string|max:255|unique:roles' , 'display_name' => 'string|max:255' , 'description' => 'max:1000' ] ) ; if ( $ validator -> fails ( ) ) { return response ( ) -> json ( arrayView ( 'phpsoft.users::e...
Create role action
5,356
public function update ( Request $ request , $ id = null ) { $ validator = Validator :: make ( $ request -> all ( ) , [ 'name' => 'sometimes|required|string|max:255|unique:roles,name,' . $ id , 'display_name' => 'string|max:255' , 'description' => 'max:1000' ] ) ; if ( $ validator -> fails ( ) ) { return response ( ) -...
Update role action
5,357
public function store ( Request $ request ) { $ validator = Validator :: make ( $ request -> all ( ) , [ 'name' => 'required|string|max:255' , 'email' => 'required|email|max:255|unique:users' , 'password' => 'required|string|confirmed|min:6' , 'username' => 'string|max:30' , 'country' => 'string|max:100' , 'location' =...
Create user action
5,358
public function update ( Request $ request , $ id = null ) { $ this -> registerValidators ( ) ; if ( ! $ id && ! $ this -> checkAuth ( ) ) { return response ( ) -> json ( null , 401 ) ; } $ user = $ id ? AppUser :: find ( $ id ) : Auth :: user ( ) ; if ( ! $ user ) { return response ( ) -> json ( null , 404 ) ; } $ req...
Update profile action
5,359
public function moveToTrash ( $ id ) { $ user = AppUser :: find ( $ id ) ; if ( ! $ user ) { return response ( ) -> json ( null , 404 ) ; } if ( ! $ user -> delete ( ) ) { return response ( ) -> json ( null , 500 ) ; } return response ( ) -> json ( null , 204 ) ; }
move user to trash
5,360
public function store ( Request $ request ) { $ validator = Validator :: make ( $ request -> all ( ) , [ 'name' => 'required|string|max:255|unique:permissions' , 'display_name' => 'string|max:255' , 'description' => 'max:1000' ] ) ; if ( $ validator -> fails ( ) ) { return response ( ) -> json ( arrayView ( 'phpsoft.us...
Create permission action
5,361
public function update ( Request $ request , $ id = null ) { $ validator = Validator :: make ( $ request -> all ( ) , [ 'name' => 'sometimes|required|string|max:255|unique:permissions,name,' . $ id , 'display_name' => 'string|max:255' , 'description' => 'max:1000' ] ) ; if ( $ validator -> fails ( ) ) { return response...
Update permission action
5,362
public static function browseByUser ( $ options = [ ] ) { $ find = $ options [ 'user' ] -> roles ( ) ; $ total = $ find -> count ( ) ; if ( ! empty ( $ options [ 'order' ] ) ) { foreach ( $ options [ 'order' ] as $ field => $ direction ) { $ find = $ find -> orderBy ( $ field , $ direction ) ; } } if ( ! empty ( $ opti...
get all role of user
5,363
public function registerClientScript ( ) { $ view = $ this -> view ; ToggleAsset :: register ( $ view ) ; $ options = Json :: encode ( $ this -> options ) ; $ js [ ] = "jQuery('$this->selector').bootstrapToggle($options);" ; if ( ! empty ( $ this -> clientEvents ) ) { foreach ( $ this -> clientEvents as $ event => $ ha...
Registers Bootstrap Switch plugin and related events
5,364
public static function findByCriteria ( array $ criteria ) : ? Model \ Collection { try { list ( $ columns , $ values , $ options ) = static :: parseCriteria ( $ criteria ) ; } catch ( NoTagsException $ e ) { return null ; } if ( \ count ( $ columns ) < 1 ) { return static :: findAll ( $ options ) ; } return static :: ...
Find the records by criteria .
5,365
public static function findOneByCriteria ( array $ criteria ) : ? self { try { list ( $ columns , $ values , $ options ) = static :: parseCriteria ( $ criteria ) ; } catch ( NoTagsException $ e ) { return null ; } if ( \ count ( $ columns ) < 1 ) { return null ; } return static :: findOneBy ( $ columns , $ values , $ o...
Find the record by criteria .
5,366
protected static function parseCriteria ( array $ criteria ) : array { $ columns = [ ] ; $ values = [ ] ; $ options = [ 'order' => 'name' ] ; if ( $ criteria [ 'source' ] ) { $ columns [ ] = 'source=?' ; $ values [ ] = $ criteria [ 'source' ] ; } if ( $ criteria [ 'alias' ] ) { $ columns [ ] = 'alias=?' ; $ values [ ] ...
Parse the criteria .
5,367
protected function respond ( $ event , $ error , $ status , $ payload = [ ] ) { $ response = $ this -> events -> fire ( $ event , $ payload , true ) ; return $ response ? : $ this -> response -> json ( arrayView ( 'phpsoft.users::errors/authenticate' , [ 'error' => $ error ] ) , $ status ) ; }
Fire event and return the response
5,368
public function load ( $ file ) { $ resource = new ZipFileResource ( $ file ) ; $ package = $ resource -> getXML ( 'META-INF/container.xml' ) ; if ( ! $ opfFile = ( string ) $ package -> rootfiles -> rootfile [ 'full-path' ] ) { $ ns = $ package -> getNamespaces ( ) ; foreach ( $ ns as $ key => $ value ) { $ package ->...
Reads in a ePub file and builds the Package definition
5,369
public function addFormConfigurationModifier ( FormConfigurationModifierInterface $ modifier , $ priority = 0 ) { $ this -> formConfigurationModifiers [ $ priority ] [ ] = $ modifier ; $ this -> needsSorting = true ; }
Adds modifier for form s configuration
5,370
public function addFormFieldResolver ( FormFieldResolverInterface $ resolver , $ priority = 0 ) { $ this -> formFieldResolvers [ $ priority ] [ ] = $ resolver ; $ this -> needsSorting = true ; }
Adds resolver for form s fields
5,371
public function addFormViewProvider ( FormViewProviderInterface $ provider , $ priority = 0 ) { $ this -> formViewProviders [ $ priority ] [ ] = $ provider ; $ this -> needsSorting = true ; }
Adds provider for defining default fields for form
5,372
private function sortRegisteredServices ( ) { krsort ( $ this -> formConfigurationModifiers ) ; if ( ! empty ( $ this -> formConfigurationModifiers ) ) { $ this -> sortedFormConfigurationModifiers = call_user_func_array ( 'array_merge' , $ this -> formConfigurationModifiers ) ; } krsort ( $ this -> formFieldResolvers )...
Sorts all registered adjusters by priority .
5,373
public function compile ( \ Twig_Compiler $ compiler ) { $ compiler -> addDebugInfo ( $ this ) ; $ compiler -> write ( '$highlighter = \Ramsey\Twig\CodeBlock\Highlighter\HighlighterFactory::getHighlighter(' ) -> string ( $ this -> getHighlighterName ( ) ) -> raw ( ', ' ) -> repr ( $ this -> getHighlighterArgs ( ) ) -> ...
Compiles the node into PHP code for execution by Twig
5,374
protected function getFigcaption ( ) { $ figcaption = '' ; if ( $ this -> hasAttribute ( 'title' ) ) { $ figcaption = '<figcaption class="code-highlight-caption">' ; $ figcaption .= '<span class="code-highlight-caption-title">' ; $ figcaption .= $ this -> getAttribute ( 'title' ) ; $ figcaption .= '</span>' ; $ figcapt...
Returns the figcaption HTML element for the codeblock
5,375
protected function getFigcaptionLink ( ) { $ link = '' ; if ( $ this -> hasAttribute ( 'linkUrl' ) ) { $ link = '<a class="code-highlight-caption-link" href="' . $ this -> getAttribute ( 'linkUrl' ) . '">' ; $ link .= $ this -> getFigcaptionLinkText ( ) ; $ link .= '</a>' ; } return $ link ; }
Returns the link for the figcaption if applicable
5,376
protected function generateConfig ( ) : array { $ config = [ 'addLabel' => $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'cfg_tags.add' ] , 'allowCreate' => isset ( $ this -> tagsCreate ) ? ( bool ) $ this -> tagsCreate : true , ] ; if ( isset ( $ this -> maxItems ) ) { $ config [ 'maxItems' ] = ( int ) $ this -> maxItems ; } re...
Generate the widget configuration .
5,377
protected function getValueTags ( ) : CollectionInterface { return $ this -> tagsManager -> findMultiple ( [ 'values' => \ is_array ( $ this -> varValue ) ? $ this -> varValue : [ ] ] ) ; }
Get the value tags .
5,378
private function generateAllTags ( CollectionInterface $ tags ) : array { $ return = [ ] ; foreach ( $ tags as $ tag ) { $ return [ ] = [ 'value' => $ tag -> getValue ( ) , 'text' => StringUtil :: decodeEntities ( $ tag -> getName ( ) ) ] ; } return $ return ; }
Generate all tags .
5,379
public function store ( Request $ request ) { $ this -> registerValidators ( ) ; $ validator = Validator :: make ( $ request -> all ( ) , [ 'route' => 'required|max:255|string|unique:route_permission,route' , 'permissions' => 'required|max:255|array|rolePermission' , 'roles' => 'required|max:255|array|rolePermission' ]...
Create route permission action
5,380
public function update ( $ id , Request $ request ) { $ routePermission = RoutePermission :: find ( $ id ) ; if ( $ routePermission == null ) { return response ( ) -> json ( null , 404 ) ; } $ this -> registerValidators ( ) ; $ validator = Validator :: make ( $ request -> all ( ) , [ 'route' => 'sometimes|required|stri...
Update permissions and roles for a route
5,381
public function destroy ( $ id ) { $ routePermission = RoutePermission :: find ( $ id ) ; if ( ! $ routePermission ) { return response ( ) -> json ( null , 404 ) ; } if ( ! ( Auth :: user ( ) && Auth :: user ( ) -> hasRole ( 'admin' ) ) ) { return response ( ) -> json ( null , 403 ) ; } $ deleteRoutePermission = $ rout...
Delete route permission
5,382
public function show ( $ id ) { $ routePermission = RoutePermission :: find ( $ id ) ; if ( ! $ routePermission ) { return response ( ) -> json ( null , 404 ) ; } return response ( ) -> json ( arrayView ( 'phpsoft.users::routePermission/read' , [ 'routePermission' => $ routePermission ] ) , 200 ) ; }
View route permission
5,383
public function getAllRoutes ( ) { $ routes = Route :: getRoutes ( ) ; $ results = [ ] ; if ( $ routes != null ) { foreach ( $ routes as $ route ) { $ route = array ( 'method' => $ route -> getMethods ( ) , 'uri' => $ route -> getPath ( ) ) ; $ results [ ] = ( object ) $ route ; } } return response ( ) -> json ( arrayV...
List all routes in app
5,384
public function parse ( \ Twig_Token $ token ) { $ this -> parseCodeBlock ( ) ; return new CodeBlockNode ( $ this -> highlighterName , $ this -> highlighterArgs , $ this -> getAttributes ( ) , $ this -> getBody ( ) , $ token -> getLine ( ) , $ this -> getTag ( ) ) ; }
Parses the codeblock tag and returns a node for Twig to use
5,385
protected function parseCodeBlock ( ) { $ stream = $ this -> parser -> getStream ( ) ; while ( ! $ stream -> getCurrent ( ) -> test ( \ Twig_Token :: BLOCK_END_TYPE ) ) { $ this -> parseEncounteredToken ( $ stream -> getCurrent ( ) , $ stream ) ; } $ stream -> expect ( \ Twig_Token :: BLOCK_END_TYPE ) ; $ this -> body ...
Parses the options found on the codeblock tag for use by the node
5,386
protected function parseEncounteredToken ( \ Twig_Token $ token , \ Twig_TokenStream $ stream ) { switch ( $ token -> getValue ( ) ) { case 'lang' : $ this -> attributes [ 'lang' ] = $ this -> parseLangOption ( $ token , $ stream ) ; break ; case 'format' : $ this -> attributes [ 'format' ] = $ this -> parseFormatOptio...
Parses each specific token found when looping through the codeblock tag
5,387
protected function parseLangOption ( \ Twig_Token $ token , \ Twig_TokenStream $ stream ) { $ this -> testToken ( 'lang' , $ token , $ stream ) ; return $ this -> getNextExpectedStringValueFromStream ( $ stream , \ Twig_Token :: STRING_TYPE ) ; }
Returns the programming language option value from the lang token
5,388
protected function parseStartOption ( \ Twig_Token $ token , \ Twig_TokenStream $ stream ) { $ this -> testToken ( 'start' , $ token , $ stream ) ; return $ this -> getNextExpectedStringValueFromStream ( $ stream , \ Twig_Token :: NUMBER_TYPE ) ; }
Returns the start option value from the start token
5,389
protected function parseMarkOption ( \ Twig_Token $ token , \ Twig_TokenStream $ stream ) { $ this -> testToken ( 'mark' , $ token , $ stream ) ; $ markValue = $ this -> getNextExpectedStringValueFromStream ( $ stream , \ Twig_Token :: NUMBER_TYPE ) ; while ( $ stream -> test ( \ Twig_Token :: OPERATOR_TYPE ) || $ stre...
Returns the mark option value from the mark token
5,390
protected function parseLinenosOption ( \ Twig_Token $ token , \ Twig_TokenStream $ stream ) { $ this -> testToken ( 'linenos' , $ token , $ stream ) ; return $ this -> getNextExpectedBoolValueFromStream ( $ stream , 'linenos' ) ; }
Returns the linenos option value from the linenos token
5,391
protected function getNextExpectedStringValueFromStream ( \ Twig_TokenStream $ stream , $ type ) { $ stream -> next ( ) ; $ stream -> expect ( \ Twig_Token :: PUNCTUATION_TYPE ) ; return $ stream -> expect ( $ type ) -> getValue ( ) ; }
Helper method for the common operation of grabbing the next string value from the stream
5,392
protected function getNextExpectedBoolValueFromStream ( \ Twig_TokenStream $ stream , $ optionName ) { $ stream -> next ( ) ; $ stream -> expect ( \ Twig_Token :: PUNCTUATION_TYPE ) ; $ expr = $ this -> parser -> getExpressionParser ( ) -> parseExpression ( ) ; if ( ! ( $ expr instanceof \ Twig_Node_Expression_Constant...
Helper method for the common operation of grabbing the next boolean value from the stream
5,393
private function getStreamFilename ( \ Twig_TokenStream $ stream ) { if ( method_exists ( $ stream , 'getFilename' ) ) { return $ stream -> getFilename ( ) ; } return $ stream -> getSourceContext ( ) -> getName ( ) ; }
Returns the filename for the given stream
5,394
public function tag ( $ tag , array $ keys ) { foreach ( $ keys as $ key ) { $ resolvedKey = $ this -> resolveAlias ( $ key ) ; if ( ! isset ( $ this -> tags [ $ tag ] ) ) { $ this -> tags [ $ tag ] = array ( ) ; } $ this -> tags [ $ tag ] [ ] = $ resolvedKey ; } $ this -> tags [ $ tag ] = array_unique ( $ this -> tags...
Assign a tag to services .
5,395
public function getTagged ( $ tag ) { $ services = array ( ) ; if ( isset ( $ this -> tags [ $ tag ] ) ) { foreach ( $ this -> tags [ $ tag ] as $ service ) { $ services [ ] = $ this -> get ( $ service ) ; } } return $ services ; }
Fetch all services registered to the given tag .
5,396
public function has ( $ key ) { $ key = $ this -> resolveAlias ( $ key ) ; $ exists = ( bool ) $ this -> getRaw ( $ key ) ; if ( $ exists === false && $ this -> parent instanceof ContainerInterface ) { $ exists = $ this -> parent -> has ( $ key ) ; } return $ exists ; }
Method to check if specified dataStore key exists .
5,397
public function add ( ManagerInterface $ manager , string $ alias ) : void { $ manager -> setAlias ( $ alias ) ; if ( $ manager instanceof DefaultManager ) { $ manager -> setDatabase ( $ this -> db ) ; } $ this -> managers [ $ alias ] = $ manager ; }
Add the manager .
5,398
public function get ( string $ alias ) : ManagerInterface { if ( ! \ array_key_exists ( $ alias , $ this -> managers ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'The manager "%s" does not exist' , $ alias ) ) ; } return $ this -> managers [ $ alias ] ; }
Get the manager .
5,399
private function getXmlAttributes ( $ xml ) { $ attributes = array ( ) ; foreach ( $ this -> namespaces as $ prefix => $ namespace ) { foreach ( $ xml -> attributes ( $ namespace ) as $ attr => $ value ) { if ( $ prefix !== "" ) { $ attr = "{$prefix}:{$attr}" ; } $ attributes [ $ attr ] = $ value ; } } return $ attribu...
Builds an array from XML attributes