idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
54,300
private function initializeService ( $ serviceId , array $ constructorArguments ) { if ( ! isset ( $ this -> config -> services [ $ serviceId ] ) ) { throw new ApplicationException ( sprintf ( "Service '%s' not configured." , $ serviceId ) ) ; } $ configData = $ this -> config -> services [ $ serviceId ] ; $ class = $ ...
create and initialize a service instance
54,301
private function initializePlugin ( $ pluginId ) { $ configData = $ this -> config -> plugins [ $ pluginId ] ; $ class = str_replace ( '/' , '\\' , $ configData [ 'class' ] ) ; $ file = $ this -> rootPath . 'src/' . $ configData [ 'classPath' ] . $ class . '.php' ; if ( ! file_exists ( $ file ) ) { throw new Applicatio...
create initialize and register a plugin instance
54,302
public function setFields ( array $ fields ) { $ this -> _fields = array ( ) ; $ this -> _records = array ( ) ; $ prevLevel = null ; foreach ( $ fields as $ field ) { $ level = $ field -> getLevel ( ) ; if ( $ level === 0 ) { $ this -> append ( $ field ) ; } else { if ( $ level === 1 && $ prevLevel !== 1 ) { $ localRec...
Set the record s fields .
54,303
public function getLocalRecordByILN ( $ iln ) { foreach ( $ this -> getLocalRecords ( ) as $ localRecord ) { if ( $ localRecord -> getILN ( ) == $ iln ) { return $ localRecord ; } } return null ; }
Return a local record identified by its ILN .
54,304
public function getAllPublishablePosts ( ) { $ collection = $ this -> getAll ( ) -> sortByDesc ( 'updated_at' ) ; $ filtered = $ collection -> filter ( function ( $ item ) { if ( $ item -> enabled == 1 ) return true ; } ) ; $ filtered = $ filtered -> filter ( function ( $ item ) { $ todaysDate = DatesHelper :: todaysDa...
Get all the posts
54,305
public function getCategoryTitleById ( $ categoryId ) { $ category = DB :: table ( 'categories' ) -> where ( 'id' , '=' , $ categoryId ) -> first ( ) ; return $ category -> title ; }
Find the category title by the category s id
54,306
public function getTagTitlesByPostId ( $ postId ) { $ post_tags = DB :: table ( 'post_tag' ) -> where ( 'post_id' , '=' , $ postId ) -> get ( ) ; if ( empty ( $ post_tags ) ) { return $ post_tags ; } $ tagTitles = [ ] ; foreach ( $ post_tags as $ post_tag ) { $ tag = DB :: table ( 'tags' ) -> select ( 'title' ) -> wher...
Find the tag s titles for those tags that are associated with a post .
54,307
public static function addHeader ( $ type , $ value , $ code = null ) { if ( false == is_string ( $ type ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ type ) ) , E_USER_ERROR ) ; } if ( false == is_string ( $ value ) && false == is_n...
Sets the response header by type and value
54,308
public static function removeHeader ( $ type ) { if ( false == is_string ( $ type ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ type ) ) , E_USER_ERROR ) ; } header_remove ( $ type ) ; }
Remove response header by type
54,309
public static function file ( File $ file , $ filename = null , $ mime = null ) { if ( null !== $ filename && false === is_string ( $ filename ) ) { return trigger_error ( sprintf ( 'Argument 2 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ filename ) ) , E_USER_ERROR ) ; } if ( null ...
Give a file for the client to download
54,310
public function setPluginManager ( Navigation \ PluginManager $ plugins ) { if ( $ this -> view ) { $ plugins -> setView ( $ this -> view ) ; } $ this -> plugins = $ plugins ; return $ this ; }
Set manager for retrieving navigation helpers
54,311
public function getPluginManager ( ) { if ( null === $ this -> plugins ) { $ this -> setPluginManager ( new Navigation \ PluginManager ( ) ) ; } return $ this -> plugins ; }
Retrieve plugin loader for navigation helpers
54,312
static public function createFromFile ( $ pathname ) { if ( ! file_exists ( $ pathname ) ) { throw new ImageFileNotFoundException ( $ pathname ) ; } $ ii = getimagesize ( $ pathname ) ; $ width = $ ii [ 0 ] ; $ height = $ ii [ 1 ] ; $ imagetype = $ ii [ 2 ] ; $ last_modified = filemtime ( $ pathname ) ; $ exif = @ exif...
Create an ImageFileInfo from an image file
54,313
public function setSingleType ( $ singleType ) { $ allowedTypes = [ self :: SINGLE_TYPE_EXACT , self :: SINGLE_TYPE_GREATER , self :: SINGLE_TYPE_GREATER_OR_EQUAL , self :: SINGLE_TYPE_LESS , self :: SINGLE_TYPE_LESS_OR_EQUAL , ] ; if ( ! is_string ( $ singleType ) || ! in_array ( $ singleType , $ allowedTypes , true )...
Sets type for the filter treated as single .
54,314
public function setFromValuePropertyName ( $ fromValuePropertyName ) { if ( ! is_string ( $ fromValuePropertyName ) || empty ( $ fromValuePropertyName ) ) { throw new InvalidArgumentException ( '"From value property name" argument must be string and must not be empty.' ) ; } if ( ! property_exists ( $ this , $ fromValu...
Sets from value property name which contains the from value .
54,315
public function setToValuePropertyName ( $ toValuePropertyName ) { if ( ! is_string ( $ toValuePropertyName ) || empty ( $ toValuePropertyName ) ) { throw new InvalidArgumentException ( '"To value property name" argument must be string and must not be empty.' ) ; } if ( ! property_exists ( $ this , $ toValuePropertyNam...
Sets to value property name which contains the to value .
54,316
public function setFromPostfix ( $ fromPostfix ) { if ( ! is_string ( $ fromPostfix ) || empty ( $ fromPostfix ) ) { throw new InvalidArgumentException ( '"From postfix" argument must be string and must not be empty.' ) ; } $ this -> fromPostfix = $ fromPostfix ; return $ this ; }
Sets from name postfix .
54,317
public function setToPostfix ( $ toPostfix ) { if ( ! is_string ( $ toPostfix ) || empty ( $ toPostfix ) ) { throw new InvalidArgumentException ( '"To postfix" argument must be string and must not be empty.' ) ; } $ this -> toPostfix = $ toPostfix ; return $ this ; }
Sets to name postfix .
54,318
public function setRangedFromType ( $ rangedFromType ) { $ allowedTypes = [ self :: RANGED_FROM_TYPE_GREATER , self :: RANGED_FROM_TYPE_GREATER_OR_EQUAL ] ; if ( ! is_string ( $ rangedFromType ) || ! in_array ( $ rangedFromType , $ allowedTypes , true ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid "range...
Sets from type for the filter treated as ranged .
54,319
public function setRangedToType ( $ rangedToType ) { $ allowedTypes = [ self :: RANGED_TO_TYPE_LESS , self :: RANGED_TO_TYPE_LESS_OR_EQUAL ] ; if ( ! is_string ( $ rangedToType ) || ! in_array ( $ rangedToType , $ allowedTypes ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid "ranged to type" argument. Allo...
Sets to type for the filter treated as ranged .
54,320
public function setFormFieldTypeRangedFrom ( $ formFieldTypeRangedFrom ) { if ( ! is_string ( $ formFieldTypeRangedFrom ) || empty ( $ formFieldTypeRangedFrom ) ) { throw new InvalidArgumentException ( '"Form field type ranged from" argument must be string and must not be empty.' ) ; } $ this -> formFieldTypeRangedFrom...
Sets form field type for from field .
54,321
public function setFormFieldTypeRangedTo ( $ formFieldTypeRangedTo ) { if ( ! is_string ( $ formFieldTypeRangedTo ) || empty ( $ formFieldTypeRangedTo ) ) { throw new InvalidArgumentException ( '"Form field type ranged to" argument must be string and must not be empty.' ) ; } $ this -> formFieldTypeRangedTo = $ formFie...
Sets form field type for to field .
54,322
public static function iconIdentifier ( string $ iconKey , string $ separator = '_' ) : string { $ slugify = new Slugify ( [ 'separator' => $ separator ] ) ; $ iconIdentifier = $ slugify -> slugify ( $ iconKey ) ; return $ iconIdentifier ; }
Gets an icon identifier from an icon key .
54,323
public static function getIconIdentifier ( string $ iconKey , string $ separator = '_' ) : string { return self :: iconIdentifier ( $ iconKey , $ separator ) ; }
Alias for the iconIdentifier function .
54,324
public static function iconSignature ( string $ extensionKey , string $ iconIdentifier , string $ separator = '-' ) : string { $ iconSignature = mb_strtolower ( "${extensionKey}${separator}${iconIdentifier}" ) ; return $ iconSignature ; }
Gets an icon signature from an extension key and icon identifier .
54,325
public static function getIconSignature ( string $ extensionKey , string $ iconIdentifier , string $ separator = '-' ) : string { return self :: iconSignature ( $ extensionKey , $ iconIdentifier , $ separator ) ; }
Alias for the iconSignature function .
54,326
public function resolveFor ( UserIdInterface $ donorId ) { $ donor = $ this -> donorRepository -> findOneById ( $ donorId ) ; $ donee = $ this -> getResolverHandlerChain ( ) -> resolve ( $ donor ) ; $ this -> eventContext -> dispatch ( FoundDonee :: fromPair ( $ donor , $ donee ) ) ; return $ donee ; }
Resolves a donee for the incoming donor user id
54,327
private function getResolverHandlerChain ( ) { $ randomResolver = $ this -> resolverFactory -> create ( Random :: class ) ; $ nonMutualResolver = $ this -> resolverFactory -> create ( NonMutual :: class , $ randomResolver ) ; return $ this -> resolverFactory -> create ( FromExistingPair :: class , $ nonMutualResolver )...
Builds and returns the resolver handler chain
54,328
public function register ( EntityDefinition $ builder ) : void { $ this -> defs [ $ builder -> full_name ] = $ builder ; $ this -> unchecked [ ] = $ builder ; $ binding_name = str_replace ( '\\' , '.' , $ builder -> full_name ) ; $ this -> ioc -> bind ( 'bap.remodel.scopes.' . $ binding_name , function ( ) use ( $ buil...
Register an Entity definition . Note this method DOES NOT generate the classes . They are generated when needed .
54,329
protected function preSaveChecksPassed ( int $ post_id ) : bool { if ( $ post_id < 1 ) { return false ; } if ( \ defined ( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return false ; } if ( ! \ current_user_can ( \ get_post_type_object ( \ get_post_type ( $ post_id ) ) -> cap -> edit_post , $ post_id ) ) { return false ; }...
Checks to perform prior save
54,330
public function createTable ( $ name , array $ columns = array ( ) , array $ primaryKey = array ( ) , array $ foreignKeys = array ( ) , array $ indexes = array ( ) , array $ checks = array ( ) ) { $ table = new Table ( $ name ) ; foreach ( $ columns as $ column ) { if ( ! isset ( $ column [ 'options' ] ) ) { $ column [...
Creates and adds a new table .
54,331
public function setTables ( array $ tables ) { $ this -> tables = array ( ) ; foreach ( $ tables as $ table ) { $ this -> addTable ( $ table ) ; } }
Sets the schema tables .
54,332
public function getTable ( $ name ) { if ( ! $ this -> hasTable ( $ name ) ) { throw SchemaException :: schemaTableDoesNotExist ( $ this -> getName ( ) , $ name ) ; } return $ this -> tables [ $ name ] ; }
Gets a table .
54,333
public function addTable ( Table $ table ) { if ( $ this -> hasTable ( $ table -> getName ( ) ) ) { throw SchemaException :: schemaTableAlreadyExists ( $ this -> getName ( ) , $ table -> getName ( ) ) ; } $ this -> tables [ $ table -> getName ( ) ] = $ table ; if ( $ table -> getSchema ( ) !== $ this ) { $ table -> set...
Adds a table to the schema .
54,334
public function createSequence ( $ name , $ initialValue = 1 , $ incrementSize = 1 ) { $ sequence = new Sequence ( $ name , $ initialValue , $ incrementSize ) ; $ this -> addSequence ( $ sequence ) ; return $ sequence ; }
Creates and adds a new sequence .
54,335
public function setSequences ( array $ sequences ) { $ this -> sequences = array ( ) ; foreach ( $ sequences as $ sequence ) { $ this -> addSequence ( $ sequence ) ; } }
Sets the schema sequences .
54,336
public function getSequence ( $ name ) { if ( ! $ this -> hasSequence ( $ name ) ) { throw SchemaException :: schemaSequenceDoesNotExist ( $ this -> getName ( ) , $ name ) ; } return $ this -> sequences [ $ name ] ; }
Gets a sequence .
54,337
public function addSequence ( Sequence $ sequence ) { if ( $ this -> hasSequence ( $ sequence -> getName ( ) ) ) { throw SchemaException :: schemaSequenceAlreadyExists ( $ this -> getName ( ) , $ sequence -> getName ( ) ) ; } $ this -> sequences [ $ sequence -> getName ( ) ] = $ sequence ; }
Adds a sequence to the schema .
54,338
public function renameSequence ( $ oldName , $ newName ) { if ( ! $ this -> hasSequence ( $ oldName ) ) { throw SchemaException :: schemaSequenceDoesNotExist ( $ this -> getName ( ) , $ oldName ) ; } if ( $ this -> hasSequence ( $ newName ) ) { throw SchemaException :: schemaSequenceAlreadyExists ( $ this -> getName ( ...
Renames a sequence .
54,339
public function dropSequence ( $ name ) { if ( ! $ this -> hasSequence ( $ name ) ) { throw SchemaException :: schemaSequenceDoesNotExist ( $ this -> getName ( ) , $ name ) ; } unset ( $ this -> sequences [ $ name ] ) ; }
Drops a sequence .
54,340
public function createView ( $ name , $ sql = null ) { $ view = new View ( $ name , $ sql ) ; $ this -> addView ( $ view ) ; return $ view ; }
Creates and adds a new view .
54,341
public function setViews ( array $ views ) { $ this -> views = array ( ) ; foreach ( $ views as $ view ) { $ this -> addView ( $ view ) ; } }
Sets the schema views .
54,342
public function getView ( $ name ) { if ( ! $ this -> hasView ( $ name ) ) { throw SchemaException :: schemaViewDoesNotExist ( $ this -> getName ( ) , $ name ) ; } return $ this -> views [ $ name ] ; }
Gets a view .
54,343
public function addView ( View $ view ) { if ( $ this -> hasView ( $ view -> getName ( ) ) ) { throw SchemaException :: schemaViewAlreadyExists ( $ this -> getName ( ) , $ view -> getName ( ) ) ; } $ this -> views [ $ view -> getName ( ) ] = $ view ; }
Adds a view to the schema .
54,344
public function renameView ( $ oldName , $ newName ) { if ( ! $ this -> hasView ( $ oldName ) ) { throw SchemaException :: schemaViewDoesNotExist ( $ this -> getName ( ) , $ oldName ) ; } if ( $ this -> hasView ( $ newName ) ) { throw SchemaException :: schemaViewAlreadyExists ( $ this -> getName ( ) , $ newName ) ; } ...
Renames a view .
54,345
public function dropView ( $ name ) { if ( ! $ this -> hasView ( $ name ) ) { throw SchemaException :: schemaViewDoesNotExist ( $ this -> getName ( ) , $ name ) ; } unset ( $ this -> views [ $ name ] ) ; }
Drops a view .
54,346
protected function prepareAttributes ( array $ attributes ) { foreach ( $ attributes as $ key => $ value ) { if ( is_numeric ( $ key ) ) { unset ( $ attributes [ $ key ] ) ; $ attributes [ $ value ] = true ; continue ; } } if ( isset ( $ attributes [ 'null' ] ) ) { unset ( $ attributes [ 'null' ] ) ; $ attributes [ 'no...
Prepares attributes changes them into key value pairs
54,347
public function table ( $ table = null ) { if ( $ table !== null ) { $ this -> table = $ table ; } return $ this -> table ; }
Returns table owning the field
54,348
public function negotiateRequestFormat ( Request $ req ) { $ header = $ req -> headers -> get ( 'Content-Type' ) ; $ exp = explode ( ';' , $ header ) ; $ type = $ exp [ 0 ] ; return isset ( $ this -> inputFormatMap [ $ type ] ) ? $ this -> inputFormatMap [ $ type ] : false ; }
Return the incoming format derived from the Requests content - type header . Generally this is used for determing which format to use during deserialization .
54,349
public function negotiateResponseFormat ( Request $ req ) { return $ this -> getFormatNegotiator ( ) -> getBestFormat ( $ req -> headers -> get ( 'Accept' ) , $ this -> formatPriorities ) ; }
Return the response format type derived from a Request s Accept header and configured priorities .
54,350
public function negotiateResponseLanguage ( Request $ req ) { return $ this -> getLanguageNegotiator ( ) -> getBest ( $ req -> headers -> get ( 'Accept-Language' ) , $ this -> langPriorities ) -> getValue ( ) ; }
Return preferred language derived from Requests Accept - Language header and configured priorities .
54,351
public function http_get ( $ url , $ data_type = 'json' ) { $ cl = curl_init ( ) ; if ( stripos ( $ url , 'https://' ) !== FALSE ) { curl_setopt ( $ cl , CURLOPT_SSL_VERIFYPEER , FALSE ) ; curl_setopt ( $ cl , CURLOPT_SSL_VERIFYHOST , FALSE ) ; curl_setopt ( $ cl , CURLOPT_SSLVERSION , 1 ) ; } curl_setopt ( $ cl , CURL...
http curl get
54,352
protected function hasRole ( $ role ) { if ( ! $ this -> container -> has ( 'security.authorization_checker' ) ) { throw new \ LogicException ( 'The SecurityBundle is not registered in your application.' ) ; } return false !== $ this -> get ( 'security.authorization_checker' ) -> isGranted ( $ role ) ; }
Checks whether the current user has the specified role or not
54,353
public function button ( $ value , $ name = null ) { Argument :: i ( ) -> test ( 1 , 'string' ) -> test ( 2 , 'string' , 'null' ) -> test ( 3 , 'bool' ) ; $ field = Button :: i ( ) -> setValue ( $ value ) ; if ( ! is_null ( $ name ) ) { $ field -> setName ( $ name ) ; } return $ field ; }
Returns a ui button field
54,354
public function checkbox ( $ name = null , $ value = null , $ items = array ( ) ) { Argument :: i ( ) -> test ( 1 , 'string' , 'null' ) -> test ( 2 , 'scalar' , 'array' , 'null' ) -> test ( 3 , 'string' , 'array' ) ; $ field = Checkbox :: i ( ) -> setItems ( $ items ) ; if ( ! is_null ( $ name ) ) { $ field -> setName ...
Returns a checkbox field or fieldset
54,355
public function password ( $ name = null , $ value = null ) { Argument :: i ( ) -> test ( 1 , 'string' , 'null' ) -> test ( 2 , 'scalar' , 'null' ) ; $ field = Password :: i ( ) ; if ( ! is_null ( $ name ) ) { $ field -> setName ( $ name ) ; } if ( ! is_null ( $ value ) ) { $ field -> setValue ( $ value ) ; } return $ ...
Returns a password field
54,356
public function radio ( $ name = null , $ value = null , array $ items = array ( ) ) { Argument :: i ( ) -> test ( 1 , 'string' , 'null' ) -> test ( 2 , 'scalar' , 'null' ) ; $ field = Radio :: i ( $ name ) -> setItems ( $ items ) ; if ( ! is_null ( $ name ) ) { $ field -> setName ( $ name ) ; } if ( ! is_null ( $ valu...
Returns a radio fieldset
54,357
public function select ( $ name = null , $ value = null , array $ items = array ( ) ) { Argument :: i ( ) -> test ( 1 , 'string' , 'null' ) -> test ( 2 , 'scalar' , 'null' ) ; $ field = Select :: i ( ) -> setItems ( $ items ) ; if ( ! is_null ( $ name ) ) { $ field -> setName ( $ name ) ; } if ( ! is_null ( $ value ) )...
Returns a select field
54,358
public function submit ( $ value , $ name = null , $ image = null ) { Argument :: i ( ) -> test ( 1 , 'string' ) -> test ( 2 , 'string' , 'null' ) ; $ field = Submit :: i ( ) -> setValue ( $ value ) ; if ( ! is_null ( $ name ) ) { $ field -> setName ( $ name ) ; } if ( $ image ) { $ field -> setImage ( $ image ) ; } re...
Returns a submit field
54,359
public function mask ( $ pattern , $ placeholder = null , $ name = null , $ value = null ) { Argument :: i ( ) -> test ( 1 , 'string' ) -> test ( 2 , 'string' , 'null' ) -> test ( 3 , 'string' , 'null' ) -> test ( 4 , 'scalar' , 'null' ) ; $ field = Mask :: i ( ) -> setPattern ( $ pattern ) ; if ( ! is_null ( $ name ) ...
Returns an input mask
54,360
public function text ( $ name = null , $ value = null ) { Argument :: i ( ) -> test ( 1 , 'string' , 'null' ) -> test ( 2 , 'scalar' , 'null' ) ; $ field = Text :: i ( ) ; if ( ! is_null ( $ name ) ) { $ field -> setName ( $ name ) ; } if ( ! is_null ( $ value ) ) { $ field -> setValue ( $ value ) ; } return $ field ; ...
Returns a text field
54,361
public function textarea ( $ name = null , $ value = null ) { Argument :: i ( ) -> test ( 1 , 'string' , 'null' ) -> test ( 2 , 'scalar' , 'null' ) ; $ field = Textarea :: i ( ) ; if ( ! is_null ( $ name ) ) { $ field -> setName ( $ name ) ; } if ( ! is_null ( $ value ) ) { $ field -> setValue ( $ value ) ; } return $ ...
Returns a textarea field
54,362
public function color ( $ name = null , $ value = null ) { Argument :: i ( ) -> test ( 1 , 'string' , 'null' ) -> test ( 2 , 'string' , 'null' ) ; $ field = Color :: i ( $ name ) ; if ( ! is_null ( $ name ) ) { $ field -> setName ( $ name ) ; } if ( ! is_null ( $ value ) ) { $ field -> setValue ( $ value ) ; } return $...
Returns a color field
54,363
public function combobox ( $ name = null , $ value = null ) { Argument :: i ( ) -> test ( 1 , 'string' , 'null' ) -> test ( 2 , 'scalar' , 'null' ) ; $ field = Combobox :: i ( ) ; if ( ! is_null ( $ name ) ) { $ field -> setName ( $ name ) ; } if ( ! is_null ( $ value ) ) { $ field -> setValue ( $ value ) ; } return $ ...
Returns a combobox field
54,364
public function datetime ( $ name = null , $ value = null ) { Argument :: i ( ) -> test ( 1 , 'string' , 'null' ) -> test ( 2 , 'scalar' , 'null' ) ; $ field = Datetime :: i ( ) ; if ( ! is_null ( $ name ) ) { $ field -> setName ( $ name ) ; } if ( ! is_null ( $ value ) ) { $ field -> setValue ( $ value ) ; } return $ ...
Returns a datetime field
54,365
public function file ( $ name = null , $ multiple = false , array $ accept = array ( ) ) { Argument :: i ( ) -> test ( 1 , 'string' , 'null' ) -> test ( 2 , 'bool' ) ; $ field = File :: i ( ) ; if ( ! is_null ( $ name ) ) { $ field -> setName ( $ name ) ; } if ( $ multiple ) { $ field -> setAttributes ( 'multiple' , 'm...
Returns a file field
54,366
public function image ( $ name = null , $ multiple = false ) { Argument :: i ( ) -> test ( 1 , 'string' , 'null' ) -> test ( 2 , 'bool' ) ; $ accept = array ( 'image/gif' , 'image/jpg' , 'image/jpeg' , 'image/png' ) ; return $ this -> file ( $ name , $ multiple , $ accept ) ; }
Returns an image upload field
54,367
public function markdown ( $ name = null , $ value = null ) { Argument :: i ( ) -> test ( 1 , 'string' , 'null' ) -> test ( 2 , 'scalar' , 'null' ) ; $ field = Markdown :: i ( ) ; if ( ! is_null ( $ name ) ) { $ field -> setName ( $ name ) ; } if ( ! is_null ( $ value ) ) { $ field -> setValue ( $ value ) ; } return $ ...
Returns a Markdown field
54,368
public function slider ( $ name = null , $ value = null ) { Argument :: i ( ) -> test ( 1 , 'string' , 'null' ) -> test ( 2 , 'scalar' , 'null' ) ; $ field = Text :: i ( ) -> setType ( 'range' ) ; if ( ! is_null ( $ name ) ) { $ field -> setName ( $ name ) ; } if ( ! is_null ( $ value ) ) { $ field -> setValue ( $ valu...
Returns a slider field
54,369
public function time ( $ name = null , $ value = null ) { Argument :: i ( ) -> test ( 1 , 'string' , 'null' ) -> test ( 2 , 'scalar' , 'null' ) ; $ field = Datetime :: i ( ) -> setOptions ( 'pickDate' , false ) -> setOptions ( 'format' , 'HH:mm PP' ) ; if ( ! is_null ( $ name ) ) { $ field -> setName ( $ name ) ; } if ...
Returns a time field
54,370
public function wysiwyg ( $ name = null , $ value = null ) { Argument :: i ( ) -> test ( 1 , 'string' , 'null' ) -> test ( 2 , 'scalar' , 'null' ) ; $ field = Wysiwyg :: i ( ) ; if ( ! is_null ( $ name ) ) { $ field -> setName ( $ name ) ; } if ( ! is_null ( $ value ) ) { $ field -> setValue ( $ value ) ; } return $ fi...
Returns a WYSIWYG field
54,371
public function exposed ( ) : MapInterface { return $ this -> dependencies -> reduce ( new Map ( Name :: class , MapInterface :: class ) , static function ( Map $ exposed , string $ name , Dependency $ dependency ) : Map { return $ exposed -> put ( $ dependency -> name ( ) , $ dependency -> exposed ( ) ) ; } ) ; }
Return the list of exposed services per dependency
54,372
public function check ( $ action , NodeRef & $ nodeRef , & $ newData = null , $ isRead = false ) { return $ this -> checkInternal ( $ action , $ nodeRef , $ newData , false , $ isRead ) ; }
Returns true if the user is permitted to access the node
54,373
public function checkThrow ( $ action , NodeRef & $ nodeRef , & $ newData = null , $ isRead = false ) { return $ this -> checkInternal ( $ action , $ nodeRef , $ newData , true , $ isRead ) ; }
Throws a PermissionsException if the user is unable to access the node otherwise returns true
54,374
public function renderMediaThumb ( MediaInterface $ media = null , array $ controls = array ( ) ) { if ( null !== $ media ) { $ media -> setThumb ( $ this -> thumbGenerator -> generateThumbUrl ( $ media ) ) ; } foreach ( $ controls as $ control ) { if ( ! ( array_key_exists ( 'role' , $ control ) && array_key_exists ( ...
Renders the media thumb .
54,375
public function build ( $ configs ) { foreach ( $ configs as $ config ) { $ this -> config = $ config ; $ this -> initVars ( ) ; $ this -> loadColumns ( ) ; $ this -> buildDataClasses ( ) ; $ this -> buildMapperClasses ( ) ; $ this -> generateClasses ( ) ; } return $ this ; }
Build model classes .
54,376
protected function loadColumns ( ) { $ statement = $ this -> db -> query ( 'SHOW COLUMNS FROM ' . $ this -> config -> getDbTable ( ) ) ; $ this -> columns = array ( ) ; while ( false !== ( $ column = $ statement -> fetchObject ( ) ) ) { $ this -> columns [ ] = new Column ( $ column , $ this -> config -> getDbPrefix ( )...
Load columns data .
54,377
protected function buildDataProperties ( ) { $ properties = '' ; $ hasAutoincrement = false ; foreach ( $ this -> columns as $ column ) { $ properties .= "\n" . $ column -> getProperty ( ) ; $ hasAutoincrement |= $ column -> isAutoIncrement ( ) ; } if ( $ hasAutoincrement ) { $ properties = ' /** * @var bool $ha...
Build properties var
54,378
protected function buildDataGetters ( ) { $ getters = '' ; foreach ( $ this -> columns as $ column ) { $ getters .= "\n" . $ column -> getGetter ( ) ; } $ this -> vars [ 'getters' ] = $ getters ; }
Build getters var
54,379
protected function buildDataGetterCacheKey ( ) { $ keys = array ( ) ; foreach ( $ this -> columns as $ column ) { if ( $ column -> isPrimaryKey ( ) ) { $ keys [ ] = '$this->' . $ column -> getMethodNameGet ( ) . '()' ; } } $ key = "'" . $ this -> config -> getCachePrefix ( ) . "_data_' . " . implode ( " . '_' . " , $ k...
Build cache key method
54,380
protected function buildDataSetters ( ) { $ setters = '' ; foreach ( $ this -> columns as $ column ) { $ setters .= "\n" . $ column -> getSetter ( ) ; } $ this -> vars [ 'setters' ] = $ setters ; }
Build setters var
54,381
protected function buildDataJoins ( ) { $ joins = array ( 'one' => array ( ) , 'many' => array ( ) ) ; $ joinsUse = array ( ) ; foreach ( $ this -> config -> getAllJoin ( ) as $ name => $ join ) { $ config = $ join [ 'class' ] ; if ( ! ( $ config instanceof ConfigInterface ) ) { throw new \ LogicException ( 'Joined cla...
Build join getters
54,382
protected function buildDataJoinsMany ( ConfigInterface $ config , array $ joinKeys ) { $ keys = '' ; $ joinKeys = array_flip ( $ joinKeys ) ; foreach ( $ this -> columns as $ column ) { if ( ! isset ( $ joinKeys [ $ column -> getName ( ) ] ) ) { continue ; } $ keys .= ' $mapper->addWhere(\'' . $ column -> g...
Build join many getters
54,383
protected function buildMapperFields ( ) { $ fields = array ( ) ; $ dataNamesMap = '' ; foreach ( $ this -> columns as $ column ) { $ field = $ column -> getName ( ) ; $ fields [ ] = " '" . $ field . "'" ; $ dataNamesMap .= " '" . $ field . "' => array( 'get' => '" . $ column -> getMethodN...
Build fields var
54,384
protected function buildMapperPrimaryKeys ( ) { $ fields = array ( ) ; foreach ( $ this -> columns as $ column ) { if ( $ column -> isPrimaryKey ( ) ) { $ fields [ ] = " '" . $ column -> getName ( ) . "'" ; } } $ this -> vars [ 'db_primary_keys' ] = implode ( ",\n" , $ fields ) ; }
Build primary keys var
54,385
protected function generateDataFileAbstract ( $ dir ) { $ file = $ dir . '/' . $ this -> config -> getClassname ( ) . 'Abstract.php' ; if ( ! is_readable ( $ file ) && false === file_put_contents ( $ file , '' ) ) { throw new \ RuntimeException ( 'Cannot create empty class file: ' . $ file ) ; } $ content = '<?php/** *...
Generate abstract file class .
54,386
protected function generateDataFile ( $ dir ) { $ file = $ dir . '/' . $ this -> config -> getClassname ( ) . '.php' ; if ( file_exists ( $ file ) ) { return ; } if ( ! is_readable ( $ file ) && false === file_put_contents ( $ file , '' ) ) { throw new \ RuntimeException ( 'Cannot create empty class file: ' . $ file ) ...
Generate child class if not already exists .
54,387
public function actionSave ( $ id = NULL ) { $ asModel = NULL ; if ( $ id == NULL ) { $ model = new Content ; $ model -> savePrototype ( Yii :: app ( ) -> user -> id ) ; $ this -> redirect ( '/dashboard/content/save/id/' . $ model -> id ) ; } else { $ model = $ this -> loadModel ( $ id ) ; $ asModel = ContentMetadata :...
Rndering action for the entry
54,388
static function longDateString ( $ date ) { str_replace ( 'now' , date ( 'm.d.y' ) , $ date ) ; if ( ! self :: parsable ( $ date ) ) return null ; $ r = self :: fromString ( $ date ) ; return $ r -> format ( 'M d, Y' ) ; }
Returns date in long date format
54,389
static function shortDateString ( $ date , $ separator = '/' ) { str_replace ( 'now' , date ( 'm.d.y' ) , $ date ) ; if ( ! self :: parsable ( $ date ) ) return null ; $ r = self :: fromString ( $ date ) ; return $ r -> format ( 'm' . $ separator . 'd' . $ separator . 'Y' ) ; }
Returns date in short date format
54,390
static function longTimeString ( $ time ) { str_replace ( 'now' , date ( 'h:i:s t' ) , $ time ) ; if ( ! self :: parsable ( $ time ) ) return null ; $ r = self :: fromString ( $ time ) ; return $ r -> format ( 'h:i:s a' ) ; }
Returns time in long time format
54,391
public static function parseAccept ( string $ accept , bool $ is_lang ) { if ( empty ( $ accept ) ) $ accept = "text/html;q=1.0,*/*;q=0.9" ; $ is_lang = $ is_lang && class_exists ( 'Locale' , false ) ; $ accept = explode ( "," , $ accept ) ; $ accepted = array ( ) ; foreach ( $ accept as $ type ) { if ( preg_match ( "/...
Parse the HTTP Accept headers into an array of Type = > Priority pairs .
54,392
public function accepts ( $ type ) { foreach ( $ this -> accept as $ accept_type => $ priority ) { if ( strpos ( $ accept_type , "*" ) !== false ) { $ regexp = "/" . str_replace ( "WC" , ".*" , preg_quote ( str_replace ( "*" , "WC" , $ accept_type ) , "/" ) ) . "/i" ; if ( preg_match ( $ regexp , $ type ) ) return $ pr...
Check if a specified response type is accepted by the client . When no types are specified everything is accepted .
54,393
public function compareTypes ( string $ l , string $ r ) { $ lq = $ this -> accept [ $ l ] ?? 0 ; $ rq = $ this -> accept [ $ r ] ?? 0 ; return $ lq === $ rq ? - 1 : ( $ lq < $ rq ? 1 : - 1 ) ; }
Compare the types based on the priorty in the accept header . Aliases for common types are supported .
54,394
public function sortTypes ( array & $ types ) { if ( WF :: is_numeric_array ( $ types ) ) return usort ( $ types , [ $ this , 'compareTypes' ] ) ; return uksort ( $ types , [ $ this , 'compareTypes' ] ) ; }
Sort a list by their accept priority
54,395
public function getBestResponseType ( array $ types ) { if ( empty ( $ types ) ) return "" ; $ this -> sortTypes ( $ types ) ; $ type = reset ( $ types ) ; return $ this -> accepts ( $ type ) ? current ( $ types ) : null ; }
Select the best response type to return from a list of available types .
54,396
public function chooseResponse ( array $ types ) { if ( empty ( $ types ) ) return null ; $ this -> sortTypes ( $ types ) ; $ first = reset ( $ types ) ; $ type = key ( $ types ) ; return $ this -> accepts ( $ type ) ? $ first : null ; }
Select the preferred reponse type based on a list of response types . The response types should be provided in preference of the script if any . These are then matched with the accepted response types by the client and the most preferred one is selected . If more than one type is equally desired by the client the first...
54,397
public function setDirectory ( $ directory ) { if ( ! is_dir ( $ directory ) && ! is_writable ( $ directory ) ) { throw new FileCacheException ( sprintf ( 'The directory "%s" is not directory and not writable' , $ directory ) ) ; } if ( is_null ( $ directory ) && ! $ this -> getFilesystem ( ) -> mkdir ( $ directory , 0...
Set the directory to store you re cache
54,398
public function insert ( array $ values ) : bool { $ this -> coerceDataTypesToDatabase ( $ values ) ; return $ this -> builder -> insert ( $ values ) ; }
Insert a new record into the database
54,399
public function insertGetId ( array $ values ) : int { $ this -> coerceDataTypesToDatabase ( $ values ) ; return $ this -> builder -> insertGetId ( $ values ) ; }
Insert a new record and get the value of the primary key