idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
235,300
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
235,301
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
235,302
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
235,303
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
235,304
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 .
235,305
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 .
235,306
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 .
235,307
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
235,308
protected function buildDataGetters ( ) { $ getters = '' ; foreach ( $ this -> columns as $ column ) { $ getters .= "\n" . $ column -> getGetter ( ) ; } $ this -> vars [ 'getters' ] = $ getters ; }
Build getters var
235,309
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
235,310
protected function buildDataSetters ( ) { $ setters = '' ; foreach ( $ this -> columns as $ column ) { $ setters .= "\n" . $ column -> getSetter ( ) ; } $ this -> vars [ 'setters' ] = $ setters ; }
Build setters var
235,311
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
235,312
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
235,313
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
235,314
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
235,315
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 .
235,316
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 .
235,317
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
235,318
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
235,319
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
235,320
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
235,321
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 .
235,322
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 .
235,323
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 .
235,324
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
235,325
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 .
235,326
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...
235,327
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
235,328
public function insert ( array $ values ) : bool { $ this -> coerceDataTypesToDatabase ( $ values ) ; return $ this -> builder -> insert ( $ values ) ; }
Insert a new record into the database
235,329
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
235,330
public function update ( array $ values ) : int { $ this -> coerceDataTypesToDatabase ( $ values ) ; return $ this -> builder -> update ( $ values ) ; }
Update a record in the database
235,331
protected function generateTree ( Collection $ collection , Collection $ children ) { $ children -> map ( function ( AdminMenuInterface $ menuItem ) use ( $ collection , & $ tree ) { $ tree [ ] = [ 'routeName' => $ menuItem -> getRouteName ( ) , 'cssClass' => $ menuItem -> getCssClass ( ) , 'name' => $ menuItem -> getN...
Generates a tree for given children elements
235,332
protected function injectToolbar ( Response $ response , $ params ) { if ( function_exists ( 'mb_stripos' ) ) { $ posrFunction = 'mb_strripos' ; $ substrFunction = 'mb_substr' ; } else { $ posrFunction = 'strripos' ; $ substrFunction = 'substr' ; } $ content = $ response -> getContent ( ) ; if ( false !== $ pos = $ pos...
Injects the Terrific Composer Toolbar into the given Response .
235,333
public function parseCommand ( $ originCommand ) { $ mappings = [ 'create' => [ 'create' ] , 'drop' => [ 'drop' , 'dropIfExists' ] , ] ; foreach ( $ mappings as $ key => $ mapping ) { if ( in_array ( $ originCommand , $ mapping ) ) { return $ key ; } } return null ; }
Parse origin command to human command
235,334
public function primary ( $ columns , $ name = null ) { $ this -> addCachePrimary ( $ columns ) ; return parent :: primary ( $ columns , $ name ) ; }
Store list primary to create i18n
235,335
public function build ( Connection $ connection , Grammar $ grammar ) { $ command = $ this -> parseCommand ( $ this -> commands [ 0 ] -> get ( 'name' ) ) ; $ schema = $ connection -> getSchemaBuilder ( ) ; if ( $ command === "drop" ) { $ schema -> dropIfExists ( $ this -> getI18NTableName ( ) ) ; } parent :: build ( $ ...
Overrride build function
235,336
protected function createColumn ( $ name , $ type , array $ parameters = [ ] ) { $ attributes = array_merge ( compact ( 'type' , 'name' ) , $ parameters ) ; $ column = new Fluent ( $ attributes ) ; return $ column ; }
Create column fluent
235,337
public function i18n_string ( $ name , $ length = 255 ) { $ this -> i18n_columns [ ] = $ column = $ this -> createColumn ( $ name , 'string' , compact ( 'length' ) ) ; return $ column ; }
Add i18n string field
235,338
public function i18n_char ( $ name , $ length = 255 ) { $ this -> i18n_columns [ ] = $ column = $ this -> createColumn ( $ name , 'char' , compact ( 'length' ) ) ; return $ column ; }
Add i18n char field
235,339
private function setHandle ( $ mode ) { $ this -> closeExistingHandle ( ) ; $ this -> handle = fopen ( $ this -> file , $ mode ) ; return $ this -> handle ; }
Set file handle
235,340
public function write ( $ string , $ append = true ) { $ mode = $ this -> getMode ( $ append ) ; $ this -> setHandle ( $ mode ) ; return fwrite ( $ this -> handle , $ string ) ; }
Write a string into a file
235,341
public function read ( $ length = 0 , $ asArray = false ) { if ( $ asArray && Number :: isZero ( $ length ) ) { return file ( $ this -> file ) ; } elseif ( Number :: isPositive ( $ length ) ) { $ this -> setHandle ( 'r' ) ; return fread ( $ this -> handle , $ length ) ; } else { return Collection :: implode ( $ this ->...
Read content from file
235,342
public function getSessionData ( $ key ) { self :: ensureSession ( ) ; if ( ! isset ( $ _SESSION [ $ key ] ) ) { return null ; } return $ _SESSION [ $ key ] ; }
Get data from session
235,343
private function initHeaders ( ) { if ( $ this -> headers !== null ) { return ; } $ apacheHeaders = function_exists ( 'apache_request_headers' ) ? apache_request_headers ( ) : false ; if ( $ apacheHeaders ) { foreach ( $ apacheHeaders as $ key => $ val ) { $ this -> headers [ strtoupper ( $ key ) ] = $ val ; } } else {...
Initialise the header list
235,344
public function getHeader ( $ name ) { $ this -> initHeaders ( ) ; $ name = strtoupper ( $ name ) ; if ( ! isset ( $ this -> headers [ $ name ] ) ) { return false ; } return $ this -> headers [ $ name ] ; }
Get a request header or false if it isn t set
235,345
public function tryLastModified ( $ modifiedTime ) { $ clientCache = $ this -> getHeader ( 'If-Modified-Since' ) ; if ( $ clientCache !== false ) { $ clientCache = preg_replace ( '/;.*$/' , '' , $ clientCache ) ; $ clientCacheTime = @ strtotime ( $ clientCache ) ; if ( $ modifiedTime <= $ clientCacheTime ) { header ( '...
Respond with 304 Last Modified if appropiate
235,346
public static function parse ( string $ url , string $ default_scheme = null ) { if ( substr ( $ url , 0 , 4 ) === "www." && ! empty ( $ default_scheme ) ) $ url = $ default_scheme . '://' . $ url ; elseif ( substr ( $ url , 0 , 2 ) === '//' && ! empty ( $ _SERVER [ 'REQUEST_SCHEME' ] ) ) $ url = $ _SERVER [ 'REQUEST_S...
Parse a URL
235,347
protected static function parseQuery ( $ query ) { if ( is_array ( $ query ) ) return $ query ; if ( empty ( $ query ) ) return null ; if ( ! is_string ( $ query ) ) throw new \ InvalidArgumentException ( 'Query must be associative array or string' ) ; $ query = ltrim ( $ query , '?' ) ; $ query = str_replace ( '&amp;'...
Parse a query string or array
235,348
public function setPath ( string $ path ) { $ path = '/' . ltrim ( $ path , '/' ) ; $ this -> query = null ; $ this -> fragment = null ; if ( preg_match ( '/^(.*?)(\\?([^#]*))?(#(.*))?$/u' , $ path , $ matches ) ) { $ path = $ matches [ 1 ] ; $ this -> query = ! empty ( $ matches [ 3 ] ) ? $ matches [ 3 ] : null ; $ th...
Set the path of the URL . This will unset the currently set fragment and query and overwrite them with whatever is appended in the path .
235,349
public function toString ( bool $ idn = false ) { $ o = "" ; if ( ! empty ( $ this -> scheme ) ) $ o .= $ this -> scheme . "://" ; if ( ! empty ( $ this -> username ) && ! empty ( $ this -> password ) ) $ o .= $ this -> username . ':' . $ this -> password . '@' ; $ host = $ this -> host ; if ( $ idn && preg_match ( '/[...
Convert a URL to a string .
235,350
public function setHost ( string $ hostname ) { if ( ( $ ppos = strrpos ( $ hostname , ":" ) ) !== false ) { $ this -> port = substr ( $ hostname , $ ppos + 1 ) ; $ hostname = substr ( $ hostname , 0 , $ ppos ) ; } if ( substr ( $ hostname , 0 , 4 ) === "xn--" ) $ hostname = \ idn_to_utf8 ( $ hostname ) ; $ this -> hos...
Set the host name of the URL
235,351
public function set ( string $ field , $ value ) { if ( $ value === null ) $ value = "" ; switch ( $ field ) { case "scheme" : $ this -> scheme = strtolower ( $ value ) ; return $ this ; case "port" : $ value = empty ( $ value ) ? null : ( int ) $ value ; case "username" : case "password" : case "fragment" : $ this -> ...
Set a field to a new value
235,352
public function get ( string $ field ) { if ( $ field === "secure" ) return $ this -> scheme === "https" ; if ( $ field === "port" && $ this -> port === null ) { if ( $ this -> scheme === "http" ) return 80 ; if ( $ this -> scheme === "https" ) return 443 ; if ( $ this -> scheme === "ftp" ) return 21 ; } if ( $ field =...
Get the value for a field
235,353
public function setQueryVariable ( string $ key , string $ value ) { if ( empty ( $ value ) ) unset ( $ this -> query [ $ key ] ) ; else $ this -> query [ $ key ] = $ value ; return $ this ; }
Set or update a query variable
235,354
public function getVendorPath ( ) { if ( is_null ( $ this -> vendorPath ) ) { $ installPath = $ this -> composer -> getInstallationManager ( ) -> getInstallPath ( $ this -> package ) ; $ targetDir = $ this -> package -> getName ( ) ; $ this -> vendorPath = explode ( $ targetDir , $ installPath ) [ 0 ] ; } return $ this...
Returns the vendor path of the current package
235,355
public function install ( ) { $ packages = $ this -> composer -> getPackage ( ) -> getRequires ( ) ; foreach ( $ packages as $ package ) { $ this -> packagesStatuses [ $ package -> getTarget ( ) ] = array ( 'extra' => null , 'dirs' => null ) ; $ this -> installPackage ( $ package ) ; } return $ this ; }
Installs all the assets directories of the dependency packages
235,356
public function installPackage ( $ package ) { $ jsonData = $ this -> getPackageJsonFile ( $ package ) ; $ packagesAssetsDir = $ this -> getPackageAssetsDirs ( $ jsonData ) ; if ( ! is_null ( $ packagesAssetsDir ) ) { $ this -> log ( $ package -> getTarget ( ) , self :: LOG_INFO , self :: CODE_INSTALLING_PACKAGE ) ; $ ...
Installs all the assets directories of the given package
235,357
public function getPackageJsonFile ( $ package ) { $ vendorPath = $ this -> getVendorPath ( ) ; $ targetDir = $ package -> getTarget ( ) ; $ jsonPath = $ vendorPath . $ targetDir . "/composer.json" ; if ( method_exists ( $ package , 'getJsonFile' ) ) { $ jsonFile = $ package -> getJsonFile ( $ jsonPath ) ; } else { $ j...
Returns the Json file of the given Package
235,358
public function getPackageAssetsDirs ( $ jsonData ) { $ packagesAssetsDir = null ; if ( isset ( $ jsonData [ "extra" ] [ self :: LABEL_ASSETS_DIR ] ) ) { $ packagesAssetsDir = $ jsonData [ "extra" ] [ self :: LABEL_ASSETS_DIR ] ; if ( is_string ( $ packagesAssetsDir ) ) { $ packagesAssetsDir = array ( self :: LABEL_PUB...
Returns all the assets directories contained in the given jsonData
235,359
public function installPackageDir ( $ package , $ namespace , $ packageAssetsDir ) { $ this -> log ( $ package -> getTarget ( ) , self :: LOG_INFO , self :: CODE_INSTALLING_DIR , array ( 'namespace' => $ namespace ) ) ; if ( ! isset ( $ this -> assetsDirectories [ $ namespace ] ) ) { $ this -> log ( $ package -> getTar...
Installs a specific directory from the given package
235,360
public function setCast ( $ option , $ type ) { if ( ! $ this -> isDefined ( $ option ) ) { throw new UndefinedOptionsException ( sprintf ( 'The option "%s" does not exist. Defined options are: "%s".' , $ option , implode ( '", "' , $ this -> getDefinedOptions ( ) ) ) ) ; } if ( $ type instanceof \ Closure ) { $ refClo...
Sets a cast for a specific option . The given option will be cast to the given type before any validation if possible .
235,361
protected function clearUndefinedOptions ( array $ options , $ allowUndefinedOptions ) { if ( ! $ allowUndefinedOptions ) { return $ options ; } $ undefinedOptions = array_diff ( array_keys ( $ options ) , $ this -> getDefinedOptions ( ) ) ; return array_diff_key ( $ options , array_flip ( $ undefinedOptions ) ) ; }
Clears undefined options before resolving if the appropriate flag is set .
235,362
protected function resolveCasts ( array $ options = [ ] ) { $ castOptions = $ options ; foreach ( $ options as $ option => $ value ) { if ( ! isset ( $ this -> casts [ $ option ] ) ) { continue ; } $ type = $ this -> casts [ $ option ] ; $ castOptions [ $ option ] = ( $ type instanceof \ Closure ) ? $ type ( $ value ) ...
Resolves a variable casts in the initial options .
235,363
protected function castToType ( $ value , $ type ) { switch ( $ type ) { case self :: TYPE_CAST_INT : $ newValue = filter_var ( $ value , FILTER_VALIDATE_INT , FILTER_NULL_ON_FAILURE ) ; $ value = ( null === $ newValue ) ? $ value : $ newValue ; break ; case self :: TYPE_CAST_BOOL : $ newValue = filter_var ( $ value , ...
Applies specific cast logic for each type .
235,364
public function add ( Annotation $ annotation ) { if ( ! isset ( $ this -> types [ $ annotation -> type ( ) ] ) ) { $ this -> types [ $ annotation -> type ( ) ] = [ $ annotation ] ; } else { $ this -> types [ $ annotation -> type ( ) ] [ ] = $ annotation ; } return $ this ; }
adds given annotation
235,365
public function firstNamed ( string $ type ) : Annotation { if ( $ this -> contain ( $ type ) ) { return $ this -> types [ $ type ] [ 0 ] ; } throw new \ ReflectionException ( 'Can not find annotation ' . $ type . ' for ' . $ this -> target ) ; }
returns first annotation with given type name
235,366
public function addAlias ( string $ alias , string $ original ) : self { $ this -> aliases [ $ alias ] = $ original ; return $ this ; }
Adds an alias
235,367
public function addTag ( string $ tagName , string $ src ) : self { $ this -> tagNames [ $ tagName ] = $ src ; return $ this ; }
Defines a new tag
235,368
public function make ( ) { if ( self :: $ newComponentCache === null ) { self :: $ newComponentCache = new \ IvoPetkov \ BearFramework \ Addons \ HTMLServerComponents \ Internal \ Component ( ) ; } return clone ( self :: $ newComponentCache ) ; }
Creates new component and return it
235,369
private function createCreateForm ( Country $ entity ) { $ form = $ this -> createForm ( new CountryType ( $ this -> get ( 'doctrine.orm.entity_manager' ) -> getRepository ( 'OrkestroLocaleBundle:Locale' ) ) , $ entity , array ( 'action' => $ this -> generateUrl ( 'orkestro_backend_country_create' ) , 'method' => 'POST...
Creates a form to create a Country entity .
235,370
public function newAction ( ) { $ entity = new Country ( ) ; $ form = $ this -> createCreateForm ( $ entity ) ; return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , ) ; }
Displays a form to create a new Country entity .
235,371
public function showAction ( $ iso_code ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entity = $ em -> getRepository ( 'OrkestroCountryBundle:Country' ) -> findOneBy ( array ( 'isoCode' => $ iso_code , ) ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find Country entity.' ) ; ...
Finds and displays a Country entity .
235,372
public function editAction ( $ iso_code ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entity = $ em -> getRepository ( 'OrkestroCountryBundle:Country' ) -> findOneBy ( array ( 'isoCode' => $ iso_code , ) ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find Country entity.' ) ; ...
Displays a form to edit an existing Country entity .
235,373
private function createEditForm ( Country $ entity ) { $ form = $ this -> createForm ( new CountryType ( $ this -> get ( 'doctrine.orm.entity_manager' ) -> getRepository ( 'OrkestroLocaleBundle:Locale' ) ) , $ entity , array ( 'action' => $ this -> generateUrl ( 'orkestro_backend_country_update' , array ( 'iso_code' =>...
Creates a form to edit a Country entity .
235,374
private function createDeleteForm ( $ iso_code ) { return $ this -> createFormBuilder ( ) -> setAction ( $ this -> generateUrl ( 'orkestro_backend_country_delete' , array ( 'iso_code' => $ iso_code ) ) ) -> setMethod ( 'DELETE' ) -> add ( 'submit' , 'submit' , array ( 'label' => 'Delete' ) ) -> getForm ( ) ; }
Creates a form to delete a Country entity by iso code .
235,375
protected function _createOutOfBoundsException ( $ message = null , $ code = null , RootException $ previous = null , $ argument = null ) { return new OutOfBoundsException ( $ message , $ code , $ previous , $ argument ) ; }
Creates a new Dhii Out Of Bounds exception .
235,376
public static function replace_key ( array $ array , $ oldKey , $ newKey ) : array { $ newArray = array ( ) ; foreach ( $ array as $ key => $ value ) { if ( $ key == $ oldKey ) { $ newArray = array_merge ( $ newArray , [ $ newKey => $ value ] ) ; } else { $ newArray = array_merge ( $ newArray , [ $ key => $ value ] ) ;...
Replace array key
235,377
public function set ( string $ uri , int $ method , callable $ action , bool $ default = false ) : self { if ( ( self :: METHOD_ANY & $ method ) !== $ method ) { throw new Exception \ InvalidMethodException ( "Route does not contain a valid HTTP Method." ) ; } $ this -> uri = "~" ; foreach ( explode ( "|" , $ uri ) as ...
Set Route data
235,378
public function set404Route ( callable $ action ) : self { $ this -> uri = "404RouteNotFound" ; $ this -> method = self :: METHOD_ANY ; $ this -> action = $ action ; $ this -> is404 = true ; return $ this ; }
Set 404 Route
235,379
protected function iterate ( $ value , PropertyDefinitionInterface $ definition = null ) { if ( empty ( $ value ) || ! is_array ( $ value ) ) { return $ value ; } $ type = $ definition -> getGenericType ( ) ; foreach ( $ value as $ key => $ item ) { if ( is_null ( $ item ) ) { continue ; } $ value [ $ key ] = $ this ->...
Attempte to iterate the value and cast all child items to the require generic type .
235,380
protected function castValue ( $ value , $ type ) { if ( isset ( $ this -> scalarMap [ $ type ] ) ) { $ cast = $ this -> castToScalar ( $ value , $ this -> scalarMap [ $ type ] ) ; return $ cast == $ value ? $ cast : $ value ; } if ( is_null ( $ value ) ) { return null ; } if ( ! is_array ( $ value ) && $ type === 'arr...
Cast a value to the desired type non - destructively .
235,381
protected function castToScalar ( $ value , $ type ) { if ( $ type === 'integer' ) { return ( integer ) $ value ; } if ( $ type === 'boolean' ) { return ( boolean ) $ value ; } if ( $ type === 'float' ) { return ( float ) $ value ; } if ( $ type === 'string' ) { return ( string ) $ value ; } return $ value ; }
Cast a value to the desired scalar type . Value remains unchanged if type is not scalar .
235,382
public function loadPlugins ( $ plugins ) { foreach ( $ plugins as $ plugin ) { $ pluginClass = str_replace ( ':' , '\\' , $ plugin ) ; $ this -> plugins [ ] = new $ pluginClass ( $ this -> core ) ; } }
Load all plugins from an array
235,383
public function invokePluginHook ( $ hookName ) { $ args = func_get_args ( ) ; array_shift ( $ args ) ; foreach ( $ this -> plugins as $ plugin ) { if ( method_exists ( $ plugin , $ hookName ) === false ) continue ; call_user_func_array ( array ( $ plugin , $ hookName ) , $ args ) ; } }
Invokes a specific plugin hook
235,384
protected function load ( $ field ) { if ( ! is_null ( $ this -> $ field ) || ! $ this -> delegatesCollection || ! $ this -> delegatesCollection -> containsKey ( $ key = strtolower ( $ field ) ) ) { return $ this -> $ field ; } $ loader = $ this -> delegatesCollection -> get ( $ key ) ; $ this -> delegatesCollection ->...
Load given field if able to define his value and return it .
235,385
protected function setMetas ( $ title = null , $ description = null ) { $ meta = Config :: getInstance ( ) -> get ( 'Eureka\Global\Meta' ) ; if ( $ title !== null ) { $ meta [ 'title' ] = strip_tags ( $ title . ' - ' . $ meta [ 'title' ] ) ; } if ( $ description !== null ) { $ meta [ 'description' ] = strip_tags ( $ de...
Override meta description with given description .
235,386
public static function statusClassFor ( int $ statusCode ) : string { $ class = substr ( ( string ) $ statusCode , 0 , 1 ) ; return self :: $ statusClass [ $ class ] ?? self :: STATUS_CLASS_UNKNOWN ; }
returns status class for given status code
235,387
public static function reasonPhraseFor ( int $ statusCode ) : string { if ( isset ( self :: $ reasonPhrases [ $ statusCode ] ) ) { return self :: $ reasonPhrases [ $ statusCode ] ; } throw new \ InvalidArgumentException ( 'Invalid or unknown HTTP status code ' . $ statusCode ) ; }
returns reason phrase for given status code
235,388
public static function lines ( string ... $ lines ) : string { $ head = true ; return join ( '' , array_map ( function ( $ line ) use ( & $ head ) { if ( empty ( $ line ) && $ head ) { $ head = false ; return self :: emptyLine ( ) ; } if ( $ head ) { return self :: line ( $ line ) ; } return $ line ; } , $ lines ) ) ; ...
creates valid http lines from given input lines
235,389
public static function isValidRfc ( string $ rfc ) : bool { return in_array ( $ rfc , [ self :: RFC_2616 , self :: RFC_7230 ] ) ; }
checks if given RFC is a valid and known RFC
235,390
public function toModel ( ) { $ nodeClass = $ this -> getElement ( ) -> NodeClass ; if ( $ nodeClass === 'Node' ) { throw new LogicException ( 'You must set a custom node in <node_class/> for element: ' . $ this -> getElement ( ) -> getSlug ( ) ) ; } else { throw new LogicException ( 'You must create a toModel method i...
You must implement a toModel method in a subclass of Node defined in a plugin . xml or system . xml in order to have toModel functionality .
235,391
public function setNodeRef ( $ newNodeRef ) { $ this -> fields [ 'NodeRef' ] = $ newNodeRef ; $ this -> fields [ 'Slug' ] = $ newNodeRef -> isFullyQualified ( ) ? $ newNodeRef -> getSlug ( ) : '' ; }
Changes our NodeRef
235,392
public function setSlug ( $ slug ) { if ( empty ( $ this -> fields [ 'Slug' ] ) || empty ( $ this -> fields [ 'OriginalSlug' ] ) ) { $ this -> fields [ 'NodeRef' ] = new NodeRef ( $ this -> getNodeRef ( ) -> getElement ( ) , $ slug ) ; } $ this -> fields [ 'Slug' ] = $ slug ; }
Sets the Slug
235,393
public function getNodePartials ( ) { if ( ! array_key_exists ( 'NodePartials' , $ this -> fields ) || is_null ( $ this -> fields [ 'NodePartials' ] ) ) $ this -> fields [ 'NodePartials' ] = new NodePartials ( ) ; return $ this -> fields [ 'NodePartials' ] ; }
Returns a reference to the partials for this node .
235,394
public function redirectMatching ( Request $ request ) { $ redirects = $ this -> storage -> getRedirects ( ) -> getRedirects ( ) ; $ relativeUri = '/' . $ request :: $ relativeUri ; foreach ( $ redirects as $ redirect ) { if ( preg_match_all ( $ redirect -> fromUrl , $ relativeUri , $ matches ) ) { $ toUrl = preg_repla...
Loop through the redirects and see if a redirect needs to take place
235,395
public function sitemapMatching ( $ request ) { $ sitemap = $ this -> storage -> getSitemap ( ) -> getSitemap ( ) ; $ relativeUri = '/' . $ request :: $ relativeUri ; foreach ( $ sitemap as $ sitemapItem ) { if ( $ sitemapItem -> regex ) { $ matches = array ( ) ; if ( preg_match_all ( $ sitemapItem -> url , $ relativeU...
Loop through sitemap items and see if one matches the requestUri . If it does add it tot the matchedSitemapItems array
235,396
public function connect ( $ host , $ port , $ secure = true ) { $ this -> socket -> setBlocking ( false ) ; if ( ! $ this -> socket -> connect ( $ host , $ port , $ secure ) ) { throw new Exception \ ConnectionFailedException ( sprintf ( '%s failed to %s:%d with error %s (%d).' , $ secure ? 'Secure connection' : 'Conne...
Set up a connection to the server .
235,397
protected function read ( ) { $ data = '' ; do { if ( $ this -> socket -> closed ( ) ) { throw new Exception \ ConnectionDroppedException ( 'The connection has been dropped.' ) ; } $ data .= $ this -> socket -> read ( ) ; } while ( ! preg_match ( $ this -> responseEnding , $ data ) ) ; return utf8_decode ( substr ( $ d...
Retrieve a response from the server .
235,398
public function getResponse ( RequestInterface $ request ) { $ this -> write ( $ request -> getPacket ( ) ) ; return $ request -> getResponse ( ) -> init ( $ this -> read ( ) ) ; }
Send a request to the server and construct an appropriate response .
235,399
public function setTransactionMethod ( $ method ) { if ( ! is_array ( $ this -> transactionMethods ) ) { $ this -> transactionMethods = [ $ method ] ; return $ this ; } if ( ! in_array ( $ method , $ this -> transactionMethods ) ) { $ this -> transactionMethods [ ] = $ method ; } return $ this ; }
Set transaction method .