idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
57,100
|
static public function subclassOf ( $ value , $ className , $ message = null , $ propertyPath = null ) { if ( ! is_subclass_of ( $ value , $ className ) ) { $ message = $ message ? : sprintf ( 'Class "%s" was expected to be subclass of "%s".' , static :: stringify ( $ value ) , $ className ) ; throw static :: createException ( $ value , $ message , static :: INVALID_SUBCLASS_OF , $ propertyPath , array ( 'class' => $ className ) ) ; } }
|
Assert that value is subclass of given class - name .
|
57,101
|
static public function range ( $ value , $ minValue , $ maxValue , $ message = null , $ propertyPath = null ) { static :: integer ( $ value ) ; if ( $ value < $ minValue || $ value > $ maxValue ) { $ message = $ message ? : sprintf ( 'Number "%s" was expected to be at least "%d" and at most "%d".' , static :: stringify ( $ value ) , static :: stringify ( $ minValue ) , static :: stringify ( $ maxValue ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_RANGE , $ propertyPath , array ( 'min' => $ minValue , 'max' => $ maxValue ) ) ; } }
|
Assert that value is in range of integers .
|
57,102
|
static public function min ( $ value , $ minValue , $ message = null , $ propertyPath = null ) { static :: integer ( $ value ) ; if ( $ value < $ minValue ) { $ message = $ message ? : sprintf ( 'Number "%s" was expected to be at least "%d".' , static :: stringify ( $ value ) , static :: stringify ( $ minValue ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_MIN , $ propertyPath , array ( 'min' => $ minValue ) ) ; } }
|
Assert that a value is at least as big as a given limit
|
57,103
|
static public function max ( $ value , $ maxValue , $ message = null , $ propertyPath = null ) { static :: integer ( $ value ) ; if ( $ value > $ maxValue ) { $ message = $ message ? : sprintf ( 'Number "%s" was expected to be at most "%d".' , static :: stringify ( $ value ) , static :: stringify ( $ maxValue ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_MAX , $ propertyPath , array ( 'max' => $ maxValue ) ) ; } }
|
Assert that a number is smaller as a given limit
|
57,104
|
static public function file ( $ value , $ message = null , $ propertyPath = null ) { static :: string ( $ value , $ message ) ; static :: notEmpty ( $ value , $ message ) ; if ( ! is_file ( $ value ) ) { $ message = $ message ? : sprintf ( 'File "%s" was expected to exist.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_FILE , $ propertyPath ) ; } }
|
Assert that a file exists
|
57,105
|
static public function directory ( $ value , $ message = null , $ propertyPath = null ) { static :: string ( $ value , $ message ) ; if ( ! is_dir ( $ value ) ) { $ message = $ message ? : sprintf ( 'Path "%s" was expected to be a directory.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_DIRECTORY , $ propertyPath ) ; } }
|
Assert that a directory exists
|
57,106
|
static public function readable ( $ value , $ message = null , $ propertyPath = null ) { static :: string ( $ value , $ message ) ; if ( ! is_readable ( $ value ) ) { $ message = $ message ? : sprintf ( 'Path "%s" was expected to be readable.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_READABLE , $ propertyPath ) ; } }
|
Assert that the value is something readable
|
57,107
|
static public function writeable ( $ value , $ message = null , $ propertyPath = null ) { static :: string ( $ value , $ message ) ; if ( ! is_writeable ( $ value ) ) { $ message = $ message ? : sprintf ( 'Path "%s" was expected to be writeable.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_WRITEABLE , $ propertyPath ) ; } }
|
Assert that the value is something writeable
|
57,108
|
static public function url ( $ value , $ message = null , $ propertyPath = null ) { static :: string ( $ value , $ message , $ propertyPath ) ; $ protocols = array ( 'http' , 'https' ) ; $ pattern = '~^ (%s):// ( ([\pL\pN\pS-]+\.)+[\pL]+ | \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} | \[ (?:(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){6})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:::(?:(?:(?:[0-9a-f]{1,4})):){5})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:[0-9a-f]{1,4})))?::(?:(?:(?:[0-9a-f]{1,4})):){4})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,1}(?:(?:[0-9a-f]{1,4})))?::(?:(?:(?:[0-9a-f]{1,4})):){3})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,2}(?:(?:[0-9a-f]{1,4})))?::(?:(?:(?:[0-9a-f]{1,4})):){2})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,3}(?:(?:[0-9a-f]{1,4})))?::(?:(?:[0-9a-f]{1,4})):)(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,4}(?:(?:[0-9a-f]{1,4})))?::)(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,5}(?:(?:[0-9a-f]{1,4})))?::)(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,6}(?:(?:[0-9a-f]{1,4})))?::)))) \] ) (:[0-9]+)? (/?|/\S+) $~ixu' ; $ pattern = sprintf ( $ pattern , implode ( '|' , $ protocols ) ) ; if ( ! preg_match ( $ pattern , $ value ) ) { $ message = $ message ? : sprintf ( 'Value "%s" was expected to be a valid URL starting with http or https' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_URL , $ propertyPath ) ; } }
|
Assert that value is an URL .
|
57,109
|
static public function alnum ( $ value , $ message = null , $ propertyPath = null ) { try { static :: regex ( $ value , '(^([a-zA-Z]{1}[a-zA-Z0-9]*)$)' ) ; } catch ( AssertionFailedException $ e ) { $ message = $ message ? : sprintf ( 'Value "%s" is not alphanumeric, starting with letters and containing only letters and numbers.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_ALNUM , $ propertyPath ) ; } }
|
Assert that value is alphanumeric .
|
57,110
|
static public function true ( $ value , $ message = null , $ propertyPath = null ) { if ( $ value !== true ) { $ message = $ message ? : sprintf ( 'Value "%s" is not TRUE.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_TRUE , $ propertyPath ) ; } }
|
Assert that the value is boolean True .
|
57,111
|
static public function false ( $ value , $ message = null , $ propertyPath = null ) { if ( $ value !== false ) { $ message = $ message ? : sprintf ( 'Value "%s" is not FALSE.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_FALSE , $ propertyPath ) ; } }
|
Assert that the value is boolean False .
|
57,112
|
static public function classExists ( $ value , $ message = null , $ propertyPath = null ) { if ( ! class_exists ( $ value ) ) { $ message = $ message ? : sprintf ( 'Class "%s" does not exist.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_CLASS , $ propertyPath ) ; } }
|
Assert that the class exists .
|
57,113
|
static public function implementsInterface ( $ class , $ interfaceName , $ message = null , $ propertyPath = null ) { $ reflection = new \ ReflectionClass ( $ class ) ; if ( ! $ reflection -> implementsInterface ( $ interfaceName ) ) { $ message = $ message ? : sprintf ( 'Class "%s" does not implement interface "%s".' , static :: stringify ( $ class ) , static :: stringify ( $ interfaceName ) ) ; throw static :: createException ( $ class , $ message , static :: INTERFACE_NOT_IMPLEMENTED , $ propertyPath , array ( 'interface' => $ interfaceName ) ) ; } }
|
Assert that the class implements the interface
|
57,114
|
static public function isJsonString ( $ value , $ message = null , $ propertyPath = null ) { if ( null === json_decode ( $ value ) && JSON_ERROR_NONE !== json_last_error ( ) ) { $ message = $ message ? : sprintf ( 'Value "%s" is not a valid JSON string.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_JSON_STRING , $ propertyPath ) ; } }
|
Assert that the given string is a valid json string .
|
57,115
|
static public function uuid ( $ value , $ message = null , $ propertyPath = null ) { $ value = str_replace ( array ( 'urn:' , 'uuid:' , '{' , '}' ) , '' , $ value ) ; if ( $ value === '00000000-0000-0000-0000-000000000000' ) { return ; } if ( ! preg_match ( '/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[1-5][0-9A-Fa-f]{3}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/' , $ value ) ) { $ message = $ message ? : sprintf ( 'Value "%s" is not a valid UUID.' , static :: stringify ( $ value ) ) ; throw static :: createException ( $ value , $ message , static :: INVALID_UUID , $ propertyPath ) ; } }
|
Assert that the given string is a valid UUID
|
57,116
|
static public function count ( $ countable , $ count , $ message = null , $ propertyPath = null ) { if ( $ count !== count ( $ countable ) ) { $ message = $ message ? : sprintf ( 'List does not contain exactly "%d" elements.' , static :: stringify ( $ countable ) , static :: stringify ( $ count ) ) ; throw static :: createException ( $ countable , $ message , static :: INVALID_COUNT , $ propertyPath , array ( 'count' => $ count ) ) ; } }
|
Assert that the count of countable is equal to count .
|
57,117
|
public function orderFormAction ( ) { return $ this -> render ( 'SuluSalesOrderBundle:Template:order.form.html.twig' , array ( 'systemUser' => $ this -> getSystemUserArray ( ) , 'termsOfPayment' => $ this -> getTermsArray ( self :: $ termsOfPaymentEntityName ) , 'termsOfDelivery' => $ this -> getTermsArray ( self :: $ termsOfDeliveryEntityName ) , 'orderStatus' => $ this -> getOrderStatus ( ) , 'currencies' => $ this -> getCurrencies ( $ this -> getUser ( ) -> getLocale ( ) ) , 'customerId' => Account :: TYPE_CUSTOMER , ) ) ; }
|
Returns Template for list
|
57,118
|
public function render ( ) { $ action = basename ( $ _SERVER [ 'SCRIPT_FILENAME' ] ) ; $ this -> table = new $ this -> table_class ( ) ; $ this -> table -> prepare_items ( ) ; ?> <div class="wrap"> <h2> <?php echo esc_html ( $ this -> get_title ( ) ) ?> </h2> <?php $ this -> before_table ( ) ; ?> <form action=" <?php echo esc_url ( admin_url ( $ action ) ) ?> " method="get"> <input type="hidden" name="page" value=" <?php echo esc_attr ( filter_input ( INPUT_GET , 'page' ) ) ?> " /> <?php if ( $ this -> has_search ) { $ this -> table -> search_box ( __ ( 'Search' ) , 's' ) ; } ob_start ( ) ; $ this -> table -> display ( ) ; $ content = ob_get_contents ( ) ; ob_end_clean ( ) ; $ content = preg_replace ( '#<input type="hidden" name="_wp_http_referer"[^>]+>#u' , '' , $ content ) ; echo $ content ; ?> </form> <?php $ this -> after_table ( ) ; ?> </div> <?php }
|
Render screen .
|
57,119
|
function addWidget ( $ regionBox , $ widget , $ priority = 0 ) { $ this -> __validateWidget ( $ widget ) ; $ regionBox = ( string ) $ regionBox ; if ( ! array_key_exists ( $ regionBox , $ this -> __widgets ) ) $ this -> __widgets [ $ regionBox ] = new PriorityQueue ( ) ; $ queue = $ this -> __widgets [ $ regionBox ] ; $ queue -> insert ( $ widget , $ priority ) ; return $ this ; }
|
Add Widget To Container
|
57,120
|
function getRegionWidgets ( $ regionBox ) { if ( ! array_key_exists ( $ regionBox , $ this -> __widgets ) ) return [ ] ; $ return = [ ] ; $ queue = $ this -> __widgets [ $ regionBox ] ; foreach ( $ queue as $ w ) $ return [ ] = $ w ; return $ return ; }
|
Get All Widgets In Region Box
|
57,121
|
function getWidgets ( ) { $ return = [ ] ; foreach ( array_keys ( $ this -> __widgets ) as $ region ) $ return [ $ region ] = $ this -> getRegionWidgets ( $ region ) ; return $ return ; }
|
Get All Widgets
|
57,122
|
public function startDueJobs ( $ current_time = null ) { foreach ( $ this -> jobs as $ job ) { $ schedule = CronExpression :: factory ( $ job -> schedule ) ; if ( $ schedule -> isDue ( $ current_time ) ) { $ this -> schedule -> run ( $ job ) ; } } }
|
Start Due Jobs
|
57,123
|
protected function getValue ( $ value , $ env_var , $ command ) { if ( $ this -> argument ( $ value ) ) { return $ this -> argument ( $ value ) ; } else { return fp_env ( $ env_var ) ? fp_env ( $ env_var ) : $ this -> call ( "publish:$command" ) ; } }
|
Get Value .
|
57,124
|
protected function obtainFields ( ) { $ this -> server = $ this -> getForgeServer ( ) ; $ this -> domain = $ this -> getDomain ( ) ; $ this -> project_type = $ this -> getProjectType ( ) ; $ this -> site_directory = $ this -> getSiteDirectory ( ) ; }
|
Obtain fields .
|
57,125
|
protected function createSiteOnForge ( ) { try { $ this -> info ( 'Creating site ' . $ this -> domain . ' on server ' . $ this -> server ) ; $ response = $ this -> http -> post ( $ this -> url , [ 'form_params' => [ 'domain' => $ this -> domain , 'project_type' => $ this -> project_type , 'directory' => $ this -> site_directory ] , 'headers' => [ 'X-Requested-With' => 'XMLHttpRequest' , 'Authorization' => 'Bearer ' . fp_env ( 'ACACHA_FORGE_ACCESS_TOKEN' ) ] ] ) ; return json_decode ( $ response -> getBody ( ) , true ) ; } catch ( \ Exception $ e ) { $ this -> showErrorAndDie ( $ e ) ; return null ; } }
|
Create site on Forge .
|
57,126
|
protected function siteIsAlreadyCreated ( ) { $ this -> sites = $ this -> fetchSites ( fp_env ( 'ACACHA_FORGE_SERVER' ) ) ; $ this -> site = fp_env ( 'ACACHA_FORGE_SITE' ) ; if ( in_array ( $ this -> site , collect ( $ this -> sites ) -> pluck ( 'id' ) -> toArray ( ) ) ) { return true ; } return in_array ( $ this -> domain , collect ( $ this -> sites ) -> pluck ( 'name' ) -> toArray ( ) ) ; }
|
Is site already created?
|
57,127
|
protected function executeOnError ( $ action ) { $ action .= 'OnError' ; if ( $ this -> isCallable ( $ this , $ action ) ) { $ event_name = $ this -> getModule ( ) -> getName ( ) . '.' . $ this -> getName ( ) . '.' . $ action ; $ result = $ this -> getEventManager ( ) -> dispatchBefore ( $ event_name , $ this ) ; if ( $ result !== false ) { $ result = $ this -> { $ action } ( ) ; } if ( $ result !== false ) { $ result = $ this -> getEventManager ( ) -> dispatchAfter ( $ event_name , $ this ) ; } $ result = ( $ result !== false ) ? true : $ result ; return $ result ; } return null ; }
|
Null is returned when no action OnError was found
|
57,128
|
public function getAddress ( ) { $ isUnix = $ this -> getAddressType ( ) === AF_UNIX ; $ address = array ( ) ; $ address [ 'transport' ] = $ this -> getTransport ( ) . ( $ isUnix ? ':///' : '://' ) ; $ address [ 'target' ] = $ this -> getTarget ( ) ; $ address [ 'port' ] = ( $ isUnix ? '' : ':' ) . $ this -> getTargetPort ( ) ; return implode ( '' , $ address ) ; }
|
Returns address to the socket to connect to
|
57,129
|
public function setAddressType ( $ addressType ) { if ( ! in_array ( $ addressType , array ( AF_INET , AF_INET6 , AF_UNIX ) ) ) { throw new \ DomainException ( 'Unsupported address type' ) ; } $ this -> addressType = $ addressType ; return $ this ; }
|
Sets address type
|
57,130
|
public function setTransport ( $ transport ) { if ( ! in_array ( $ transport , stream_get_transports ( ) ) ) { throw new \ DomainException ( sprintf ( 'Unsupported type of transport "%s"' , $ transport ) ) ; } $ this -> transport = $ transport ; return $ this ; }
|
Defines socket transport
|
57,131
|
public function setTargetPort ( $ targetPort ) { if ( $ this -> getAddressType ( ) != AF_UNIX && ! is_integer ( $ targetPort ) ) { throw new \ InvalidArgumentException ( 'Target port parameter must be an integer' ) ; } $ this -> targetPort = $ targetPort ; return $ this ; }
|
Sets target port
|
57,132
|
public function addConnectionFlag ( $ connectionFlag ) { if ( ! in_array ( $ connectionFlag , array ( STREAM_CLIENT_CONNECT , STREAM_CLIENT_PERSISTENT , STREAM_CLIENT_ASYNC_CONNECT ) ) ) { throw new \ InvalidArgumentException ( 'Invalid connection flag argument' ) ; } if ( ! in_array ( $ connectionFlag , $ this -> connectionFlags ) ) { $ this -> connectionFlags [ ] = $ connectionFlag ; } return $ this ; }
|
Adds a connection flag
|
57,133
|
public function connect ( ) { $ streamContext = stream_context_create ( array ( $ this -> getTransport ( ) => $ this -> getContextOptions ( ) ) ) ; $ streamResource = stream_socket_client ( $ this -> getAddress ( ) , $ errorCode , $ errorMessage , $ this -> getSocketTimeout ( ) , $ this -> getConnectionFlags ( ) , $ streamContext ) ; if ( ! $ streamResource ) { throw new \ RuntimeException ( sprintf ( 'Unable to connect on socket. Error [%d]: %s' , $ errorCode , $ errorMessage ) ) ; } stream_set_blocking ( $ streamResource , $ this -> isBlockingMode ( ) ) ; $ this -> setStreamResource ( $ streamResource ) ; return $ this ; }
|
Establishes a socket connection
|
57,134
|
public function disconnect ( ) { $ streamResource = $ this -> getStreamResource ( ) ; if ( is_resource ( $ streamResource ) ) { stream_socket_shutdown ( $ streamResource , STREAM_SHUT_RDWR ) ; $ this -> streamResource = null ; } return $ this ; }
|
Shutdowns a connection
|
57,135
|
function bind ( ) { $ sockUri = $ this -> getServerAddress ( ) ; $ scheme = parse_url ( $ sockUri , PHP_URL_SCHEME ) ; if ( ! in_array ( $ scheme , stream_get_transports ( ) ) ) throw new \ Exception ( sprintf ( 'Transport "%s" not supported.' , $ scheme ) ) ; if ( $ scheme == 'udp' ) $ socket = @ stream_socket_server ( $ sockUri , $ errno , $ errstr , STREAM_SERVER_BIND ) ; else $ socket = @ stream_socket_server ( $ sockUri , $ errno , $ errstr ) ; if ( ! $ socket ) throw new \ Exception ( sprintf ( 'Server %s, %s.' , $ this -> getServerAddress ( ) , $ errstr ) , $ errno ) ; $ this -> __socket_connected = $ socket ; return $ this ; }
|
Open Socket Connection To Socket Uri and Bind Server Socket To Specific Port
|
57,136
|
function listen ( ) { $ sockUri = $ this -> getServerAddress ( ) ; if ( ! $ this -> isBinding ( ) ) throw new \ Exception ( 'Server not bind as local server.' ) ; $ scheme = parse_url ( $ sockUri , PHP_URL_SCHEME ) ; if ( $ scheme == 'udp' ) $ resource = $ this -> _listen_to_connectLessTransport ( ) ; else $ resource = $ this -> _listen_to_connectionOrientatedTransports ( ) ; if ( $ resource === false ) throw new \ Exception ( sprintf ( 'Failed To Accept Connection, %s.' , error_get_last ( ) [ 'message' ] ) ) ; return new Streamable ( $ resource ) ; }
|
Listen On Port To Accept Data On That Port From Client
|
57,137
|
function setServerAddress ( $ socketUri ) { if ( $ this -> socketUri ) throw new \ Exception ( sprintf ( 'Server Address is Immutable; currently have value: (%s).' , $ this -> socketUri ) ) ; $ this -> socketUri = ( string ) $ socketUri ; return $ this ; }
|
Immutable Set Socket Uri
|
57,138
|
function _listen_to_connectLessTransport ( ) { stream_socket_recvfrom ( $ this -> __socket_connected , 1 , 0 , $ remotePeer ) ; $ sockUri = $ this -> getServerAddress ( ) ; $ scheme = parse_url ( $ sockUri , PHP_URL_SCHEME ) ; $ client = new StreamClient ( $ scheme . '://' . $ remotePeer ) ; $ resource = $ client -> getConnect ( ) ; return $ resource ; }
|
such as udp
|
57,139
|
function _listen_to_connectionOrientatedTransports ( ) { $ conn = @ stream_socket_accept ( $ this -> __socket_connected , $ this -> getTimeout ( ) ) ; if ( $ conn === false ) throw new exConnectionTimeout ( 'Connection Timeout.' ) ; $ resource = new ResourceStream ( $ conn ) ; return $ resource ; }
|
such as tcp
|
57,140
|
public function setExtension ( $ extension = '.png' ) { if ( substr ( $ extension , 0 , 1 ) != '.' ) { $ extension = '.' . $ extension ; } $ this -> extension = $ extension ; return $ this ; }
|
Set image extension .
|
57,141
|
public function setSize ( $ size = 32 ) { $ size = ( int ) $ size ; if ( $ size < 1 ) { $ size = 1 ; } if ( $ size > 2048 ) { $ size = 2048 ; } $ this -> size = $ size ; return $ this ; }
|
Set image size .
|
57,142
|
public function setDefault ( $ default ) { $ default = trim ( $ default ) ; if ( in_array ( ( string ) $ default , static :: $ defaultGravatars ) ) { $ this -> default = ( string ) $ default ; } elseif ( strpos ( $ default , 'http' ) !== false && filter_var ( $ default , FILTER_VALIDATE_URL ) ) { $ this -> default = urlencode ( $ default ) ; } return $ this ; }
|
Set the default gravatar should one not exist for the email .
|
57,143
|
public function setRating ( $ rating = 'g' ) { $ rating = ( string ) $ rating ; if ( in_array ( $ rating , static :: $ ageRatings ) ) { $ this -> rating = $ rating ; } return $ this ; }
|
Set age rating .
|
57,144
|
public function getGravatar ( $ email = null ) { if ( isset ( $ email ) ) { $ this -> setEmail ( ( string ) $ email ) ; } $ url = self :: BASE_URL ; if ( $ this -> secure ) { $ url = self :: BASE_URL_SECURE ; } $ url .= $ this -> email ; $ url .= $ this -> extension ; $ url .= '?s=' . $ this -> size ; $ url .= '&d=' . $ this -> default ; if ( $ this -> forceDefault ) { $ url .= '&forcedefault=y' ; } $ url .= '&rating=' . $ this -> rating ; return $ url ; }
|
Get the gravatar .
|
57,145
|
public function setEmail ( $ email = '' ) { $ email = ( string ) $ email ; $ email = trim ( $ email ) ; $ email = strtolower ( $ email ) ; if ( ! filter_var ( $ email , FILTER_VALIDATE_EMAIL ) ) { throw new \ InvalidArgumentException ( 'Email should be a valid email address' ) ; } $ this -> email = md5 ( $ email ) ; return $ this ; }
|
Set email address .
|
57,146
|
public static function connect ( $ db , $ host = 'localhost' , $ port = 27017 ) { self :: $ cnxHandler = new \ MongoClient ( $ host . ':' . $ port ) ; self :: $ db = self :: $ cnxHandler -> $ db ; if ( ! self :: $ cnxHandler || ! self :: $ db ) { return false ; } else { return true ; } }
|
Etablit la connexion avec le serveur MongoDB
|
57,147
|
public static function update ( $ collection , $ criteriaQuery , $ data , $ multiple = false ) { static :: checkConnexion ( ) ; $ collection = self :: $ db -> $ collection ; if ( is_string ( $ criteriaQuery ) ) { $ criteriaQuery = json_decode ( $ criteriaQuery , true ) ; if ( ! $ criteriaQuery ) { throw new \ Exception ( 'criteriaQuery JSON formulée incorrectement') ;
} } if ( is_string ( $ data ) ) { $ data = json_decode ( $ data , true ) ; if ( ! $ data ) { throw new \ Exception ( 'data JSON formulé incorrectement') ;
} } $ r = $ collection -> update ( $ criteriaQuery , $ data , array ( 'multiple' => $ multiple , 'upsert' => false ) ) ; if ( $ r [ 'updatedExisting' ] && $ r [ 'ok' ] ) { return true ; } return false ; }
|
Modifie un ou plusieurs documents d une collection .
|
57,148
|
public static function delete ( $ collection , $ criteriaQuery = array ( ) ) { static :: checkConnexion ( ) ; $ collection = self :: $ db -> $ collection ; if ( is_string ( $ criteriaQuery ) ) { $ criteriaQuery = json_decode ( $ criteriaQuery , true ) ; if ( ! $ criteriaQuery ) { throw new \ Exception ( 'criteriaQuery JSON formulée incorrectement') ;
} } $ r = $ collection -> remove ( $ criteriaQuery , array ( 'justOne' => false ) ) ; if ( $ r [ 'ok' ] ) { return true ; } return false ; }
|
Supprime un ou plusieurs enregistrements d une collection
|
57,149
|
public static function dropCollection ( $ collection ) { static :: checkConnexion ( ) ; $ collection = self :: $ db -> $ collection ; $ r = $ collection -> drop ( ) ; if ( $ r [ 'ok' ] ) { return true ; } return false ; }
|
Supprime une collection
|
57,150
|
public static function addCollection ( $ collection ) { static :: checkConnexion ( ) ; $ r = self :: $ db -> createCollection ( $ collection ) ; if ( gettype ( $ r ) == 'object' && get_class ( $ r ) == 'MongoCollection' ) { return true ; } return false ; }
|
Ajoute une collection
|
57,151
|
protected function exec ( $ url ) { $ client = $ this -> getRequest ( ) ; try { $ response = $ client -> request ( 'POST' , $ this -> buildRequestUrl ( ) , [ 'json' => [ 'longUrl' => $ url ] ] ) ; } catch ( \ GuzzleHttp \ Exception \ ClientException $ e ) { $ response = $ e -> getResponse ( ) ; } return $ this -> handleResponse ( $ response -> getBody ( ) ) ; }
|
Executes a CURL request to the Google API
|
57,152
|
public static function initModules ( ) { $ cfg = ServiceContainer :: get ( 'config' ) ; $ moduleList = $ cfg -> getConfigData ( 'modules' ) ; if ( count ( $ moduleList ) > 0 ) { foreach ( $ moduleList as $ moduleName ) { self :: loadModule ( $ moduleName ) ; } } }
|
Autoload modules specified in config files
|
57,153
|
public static function loadModule ( $ moduleName ) { $ moduleConf = self :: getModuleConf ( $ moduleName ) ; try { if ( isset ( $ moduleConf [ 'requires_php_extension' ] ) && is_array ( $ moduleConf [ 'requires_php_extension' ] ) ) { self :: checkPhpExtensions ( $ moduleConf [ 'requires_php_extension' ] ) ; } $ tmpModule = new \ ReflectionClass ( '\\pff\\modules\\' . $ moduleConf [ 'class' ] ) ; if ( $ tmpModule -> isSubclassOf ( '\\pff\\Abs\\AModule' ) ) { $ moduleName = strtolower ( $ moduleConf [ 'name' ] ) ; if ( isset ( self :: $ _modules [ $ moduleName ] ) ) { return self :: $ _modules [ $ moduleName ] ; } self :: $ _modules [ $ moduleName ] = $ tmpModule -> newInstance ( ) ; self :: $ _modules [ $ moduleName ] -> setModuleName ( $ moduleConf [ 'name' ] ) ; self :: $ _modules [ $ moduleName ] -> setModuleVersion ( $ moduleConf [ 'version' ] ) ; self :: $ _modules [ $ moduleName ] -> setModuleDescription ( $ moduleConf [ 'desc' ] ) ; self :: $ _modules [ $ moduleName ] -> setConfig ( ServiceContainer :: get ( 'config' ) ) ; self :: $ _modules [ $ moduleName ] -> setApp ( ServiceContainer :: get ( 'app' ) ) ; ( isset ( $ moduleConf [ 'runBefore' ] ) ) ? $ moduleLoadBefore = $ moduleConf [ 'runBefore' ] : $ moduleLoadBefore = null ; if ( isset ( $ moduleConf [ 'requires' ] ) && is_array ( $ moduleConf [ 'requires' ] ) ) { self :: $ _modules [ $ moduleName ] -> setModuleRequirements ( $ moduleConf [ 'requires' ] ) ; foreach ( $ moduleConf [ 'requires' ] as $ requiredModuleName ) { self :: loadModule ( $ requiredModuleName ) ; self :: $ _modules [ $ moduleName ] -> registerRequiredModule ( self :: $ _modules [ $ requiredModuleName ] ) ; } } if ( $ tmpModule -> isSubclassOf ( '\pff\Iface\IHookProvider' ) ) { ServiceContainer :: get ( 'hookmanager' ) -> registerHook ( self :: $ _modules [ $ moduleName ] , $ moduleName , $ moduleLoadBefore ) ; } return self :: $ _modules [ $ moduleName ] ; } else { throw new ModuleException ( "Invalid module: " . $ moduleConf [ 'name' ] ) ; } } catch ( \ ReflectionException $ e ) { throw new ModuleException ( "Unable to create module instance: " . $ e -> getMessage ( ) ) ; } }
|
Loads a module and its dependencies and then returns the module reference
|
57,154
|
public function getModule ( $ moduleName ) { $ moduleName = strtolower ( $ moduleName ) ; if ( isset ( self :: $ _modules [ $ moduleName ] ) ) { return self :: $ _modules [ $ moduleName ] ; } else { try { return $ this -> loadModule ( $ moduleName ) ; } catch ( \ Exception $ e ) { throw new ModuleException ( "Cannot find requested module: $moduleName" ) ; } } }
|
Get the instance of desired module
|
57,155
|
public function setController ( AController $ controller ) { if ( count ( self :: $ _modules ) > 0 ) { foreach ( self :: $ _modules as $ module ) { $ module -> setController ( $ controller ) ; } } }
|
Sets the Controller for each module
|
57,156
|
protected function configure ( ) { if ( ! is_null ( $ this -> signature ) ) { $ parser = new SignatureParser ( $ this ) ; $ parser -> parse ( $ this -> signature ) ; $ this -> setDescription ( $ this -> description ) ; } }
|
Configure the command if signature is set .
|
57,157
|
protected function argument ( $ key = null ) { if ( is_null ( $ key ) ) { return $ this -> input -> getArguments ( ) ; } return $ this -> input -> getArgument ( $ key ) ; }
|
Get the value of a command argument .
|
57,158
|
protected function option ( $ key = null ) { if ( is_null ( $ key ) ) { return $ this -> input -> getOptions ( ) ; } return $ this -> input -> getOption ( $ key ) ; }
|
Get the value of a command option .
|
57,159
|
public function addInput ( Input $ input ) { $ reflection = new \ ReflectionClass ( $ input ) ; $ method = 'add' . $ reflection -> getShortName ( ) ; if ( method_exists ( $ this , $ method ) ) { $ this -> $ method ( ... array_values ( $ input -> getAttributes ( ) ) ) ; } }
|
Add input to the command .
|
57,160
|
public function askPassword ( $ question ) { $ helper = $ this -> getHelper ( 'question' ) ; $ question = new Question ( $ question ) ; $ question -> setHidden ( true ) ; $ question -> setHiddenFallback ( false ) ; return $ helper -> ask ( $ this -> input , $ this -> getOutputInterface ( ) , $ question ) ; }
|
Ask a password .
|
57,161
|
public function choose ( $ question , array $ choices , $ default = null ) { $ helper = $ this -> getHelper ( 'question' ) ; $ question = new ChoiceQuestion ( $ question , $ choices , $ default ) ; $ question -> setErrorMessage ( 'Option %s is invalid.' ) ; return $ helper -> ask ( $ this -> input , $ this -> getOutputInterface ( ) , $ question ) ; }
|
Ask a question where the answer is available from a list of predefined choices .
|
57,162
|
public function anticipate ( $ question , array $ autoCompletion , $ default = null ) { $ helper = $ this -> getHelper ( 'question' ) ; $ question = new Question ( $ question , $ default ) ; $ question -> setAutocompleterValues ( $ autoCompletion ) ; return $ helper -> ask ( $ this -> input , $ this -> getOutputInterface ( ) , $ question ) ; }
|
Ask a question where some auto - completion help is provided .
|
57,163
|
public function choice ( $ question , array $ choices , $ default = null ) { $ helper = $ this -> getHelper ( 'question' ) ; $ question = new ChoiceQuestion ( $ question , $ choices , $ default ) ; $ question -> setMultiselect ( true ) ; return $ helper -> ask ( $ this -> input , $ this -> getOutputInterface ( ) , $ question ) ; }
|
Ask a question where the answer is available from a list of predefined choices and more choices can be selected .
|
57,164
|
private function prepareFilename ( $ filename ) { $ this -> filename = $ filename ; if ( ! $ this -> filename ) { $ this -> filename = $ this -> content -> getMetadata ( 'uri' ) ; } if ( ! $ this -> filename || substr ( $ this -> filename , 0 , 6 ) === 'php://' ) { $ this -> filename = $ this -> name ; } }
|
Applies a file name to the POST file based on various checks .
|
57,165
|
public function nextSequence ( $ currentSequence = null ) { $ sequenceLength = count ( $ currentSequence ) ; $ k = null ; for ( $ i = 0 ; $ i < $ sequenceLength ; $ i ++ ) { if ( isset ( $ currentSequence [ $ i + 1 ] ) && $ currentSequence [ $ i ] < $ currentSequence [ $ i + 1 ] ) { $ k = $ i ; } } if ( is_null ( $ k ) ) { return reset ( $ this -> sequenceArray ) ; } $ l = null ; for ( $ i = 0 ; $ i < $ sequenceLength ; $ i ++ ) { if ( $ currentSequence [ $ k ] < $ currentSequence [ $ i ] ) { $ l = $ i ; } } if ( is_null ( $ l ) ) { return reset ( $ this -> sequenceArray ) ; } $ nextSequence = $ currentSequence ; $ nextSequence [ $ k ] = $ currentSequence [ $ l ] ; $ nextSequence [ $ l ] = $ currentSequence [ $ k ] ; $ k2 = $ k + 1 ; if ( $ k2 < ( $ sequenceLength - 1 ) ) { for ( $ i = 0 , $ count = floor ( ( $ sequenceLength - $ k2 ) / 2 ) ; $ i < $ count ; $ i ++ ) { $ key1 = $ k2 + $ i ; $ key2 = $ sequenceLength - 1 - $ i ; $ val1 = $ nextSequence [ $ key1 ] ; $ nextSequence [ $ key1 ] = $ nextSequence [ $ key2 ] ; $ nextSequence [ $ key2 ] = $ val1 ; } } return $ nextSequence ; }
|
Get Next Sequence in order
|
57,166
|
public static function shift ( $ array , $ num ) { $ num = abs ( $ num ) + 1 ; $ n = count ( $ array ) ; $ used = array_fill ( 0 , $ n , false ) ; $ res = [ ] ; $ factorial = self :: factorial ( $ n ) ; if ( $ num > $ factorial ) { $ num = $ num % $ factorial ; if ( $ num == 0 ) { $ num = $ factorial - $ num ; } } for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) { $ factorial = self :: factorial ( $ n - $ i ) ; $ blockNum = intval ( ( $ num - 1 ) / $ factorial + 1 ) ; $ pos = 0 ; for ( $ j = 1 ; $ j < count ( $ used ) ; $ j ++ ) { if ( ! $ used [ $ j ] ) $ pos ++ ; if ( $ blockNum == $ pos ) break ; } $ res [ $ i - 1 ] = $ j - 1 ; $ used [ $ j ] = true ; $ num = intval ( ( $ num - 1 ) % $ factorial ) + 1 ; } return $ res ; }
|
Get by position
|
57,167
|
public function buildTag ( $ asset , $ type ) { $ attrs = $ this -> markSource ? $ this -> markAttr : [ ] ; switch ( $ type ) { case self :: ASSET_JS_FILE : return Html :: script ( $ asset , $ attrs ) ; break ; case self :: ASSET_JS : return Html :: scriptCode ( $ asset , $ attrs ) ; break ; case self :: ASSET_CSS_FILE : return Html :: css ( $ asset , $ attrs ) ; break ; case self :: ASSET_CSS : return Html :: style ( $ asset , $ attrs ) ; break ; } return '' ; }
|
create html tag
|
57,168
|
public function exists ( $ name , $ pos = null ) { if ( ! $ pos ) { foreach ( $ this -> getAssetTypes ( ) as $ type ) { $ assets = $ this -> getAssetsByPos ( $ type ) ; if ( isset ( $ assets [ $ name ] ) ) { return true ; } } } else { $ assets = $ this -> getAssetsByPos ( $ pos ) ; return isset ( $ assets [ $ name ] ) ; } return false ; }
|
check asset has exists
|
57,169
|
static function fromProvider ( $ provider , $ data ) { $ providername = __NAMESPACE__ . '\\providers\\' . ucfirst ( strtolower ( $ provider ) ) . 'Provider' ; return new self ( new $ providername ( $ data ) ) ; }
|
Generic instanciation method for any type of provider .
|
57,170
|
public function getPages ( ) { return ( int ) ceil ( ( float ) $ this -> provider -> count ( ) / ( float ) $ this -> pagelength ) ; }
|
Returns the total number of pages available .
|
57,171
|
public function getPagesList ( $ length = 10 ) { $ pagenum = $ this -> getPageNum ( ) ; $ pagecount = $ this -> getPages ( ) ; if ( $ length > $ pagecount ) { $ length = $ pagecount ; } $ delta = ceil ( $ length / 2 ) ; if ( $ pagenum <= 1 ) { $ lowerbound = 1 ; $ upperbound = min ( $ pagecount , $ length ) ; } else if ( $ pagenum - $ delta > $ pagecount - $ length ) { $ lowerbound = $ pagecount - $ length + 1 ; $ upperbound = $ pagecount ; } else { if ( $ pagenum - $ delta < 0 ) { $ delta = $ pagenum ; } $ offset = $ pagenum - $ delta ; $ lowerbound = $ offset + 1 ; $ upperbound = $ offset + $ length ; } return range ( $ lowerbound , $ upperbound ) ; }
|
Gets the list of pages surrounding the current one as an array .
|
57,172
|
public function setGetParams ( $ params ) { if ( ! is_array ( $ params ) ) { $ params = explode ( '&' , str_replace ( '?' , '' , $ params ) ) ; } $ get = array ( ) ; foreach ( $ params as $ varname => $ varval ) { if ( $ varname == 'p' ) continue ; if ( is_array ( $ varval ) ) { foreach ( $ varval as $ subval ) { $ get [ ] = "${varname}[]=$subval" ; } } else { $ get [ ] = "$varname=$varval" ; } } $ this -> getparams = implode ( '&' , $ get ) ; }
|
Sets the get parameters for the links .
|
57,173
|
function render ( $ class = '' , $ id = '' , $ return = false ) { $ link = $ this -> link . ( $ this -> getparams ? '?' . $ this -> getparams . '&' : '?' ) ; ?> <div <?= ( ( $ id != '' ) ? 'id="' . $ id . '"' : '' ) ?> <?= ( ( $ class != '' ) ? 'class="' . $ class . '"' : '' ) ?> > <a class="start" href=" <?= $ link ?> p=1" title="Start"> </a> <a class="back" href=" <?= $ link ?> p= <?= max ( $ this -> getPageNum ( ) - 1 , 1 ) ?> " title="Back"> </a> <? foreach ( $ this -> getPagesList ( ) as $ page ) : ?> <a class="number <?= ( $ page == $ this -> getPageNum ( ) ? ' selected' : '' ) ?> " href=" <?= $ link ?> p= <?= $ page ?> " title="Back"> <?= $ page ?> </a> <? endforeach ?> <a class="next" href=" <?= $ link ?> p= <?= min ( $ this -> getPageNum ( ) + 1 , $ this -> getPages ( ) ) ?> " title="Back"> </a> <a class="end" href=" <?= $ link ?> p= <?= $ this -> getPages ( ) ?> " title="End"> </a> </div> <?php }
|
Displays or returns the HTML list of pages .
|
57,174
|
protected function summary ( array $ parameters = [ ] ) { ksort ( $ parameters ) ; $ summary = '' ; foreach ( $ parameters as $ value ) { $ summary .= $ value ; } $ summary .= $ this -> config ( 'private_key' ) ; return md5 ( $ summary ) ; }
|
Generate control summary .
|
57,175
|
public static function checkRole ( $ roleName ) { return function ( $ params ) use ( $ roleName ) { \ Yii :: $ app -> user -> can ( $ roleName , $ params ) ; } ; }
|
Return a PHP callable that check user permission by role
|
57,176
|
public function getProgressToNextLevel ( ) { if ( $ this -> isTotal ( ) ) { return false ; } $ level = $ this -> getVirtualLevel ( ) ; $ currentLevelXp = $ this -> getSkill ( ) -> getXp ( $ level ) ; $ nextLevelXp = $ this -> getSkill ( ) -> getXp ( $ level + 1 ) ; if ( ! $ nextLevelXp ) { return false ; } $ totalXpInLevel = $ nextLevelXp - $ currentLevelXp ; $ xpInLevel = $ this -> getXp ( ) - $ currentLevelXp ; return $ xpInLevel / $ totalXpInLevel ; }
|
Returns how far to the next level this skill is from 0 - 1 .
|
57,177
|
public function getRequests ( $ asSent = false ) { return array_map ( function ( $ t ) use ( $ asSent ) { return $ asSent ? $ t [ 'sent_request' ] : $ t [ 'request' ] ; } , $ this -> transactions ) ; }
|
Get all of the requests sent through the plugin .
|
57,178
|
public function getLastRequest ( $ asSent = false ) { return $ asSent ? end ( $ this -> transactions ) [ 'sent_request' ] : end ( $ this -> transactions ) [ 'request' ] ; }
|
Get the last request sent .
|
57,179
|
public static function setUnitOfWorkEntityChangeSet ( $ entity , $ changeSet , $ unitOfWork ) { $ reflectionClass = new ReflectionClass ( UnitOfWork :: class ) ; $ reflectionProperty = $ reflectionClass -> getProperty ( 'entityChangeSets' ) ; $ reflectionProperty -> setAccessible ( true ) ; $ changeSetFull = $ reflectionProperty -> getValue ( $ unitOfWork ) ; $ changeSetFull [ $ oid = spl_object_hash ( $ entity ) ] = $ changeSet ; $ reflectionProperty -> setValue ( $ unitOfWork , $ changeSetFull ) ; }
|
Set Entity Change Set
|
57,180
|
public static function getAllEntityClassNames ( EntityManager $ entityManager ) { $ classes = [ ] ; foreach ( $ entityManager -> getMetadataFactory ( ) -> getAllMetadata ( ) as $ meta ) { $ classes [ ] = $ meta -> getName ( ) ; } return $ classes ; }
|
Get all Entity Class Names
|
57,181
|
public static function getPropertiesByAnnotation ( $ entityClass , $ annotationClass , AnnotationReader $ reader ) { $ properties = [ ] ; $ reflectionClass = new ReflectionClass ( $ entityClass ) ; foreach ( $ reflectionClass -> getProperties ( ) as $ reflectionProperty ) { if ( false === self :: hasPropertyAnnotation ( $ reflectionProperty , $ annotationClass , $ reader ) ) { continue ; } $ reflectionProperty -> setAccessible ( true ) ; $ properties [ ] = $ reflectionProperty ; } return $ properties ; }
|
Get Properties by Annotation
|
57,182
|
public static function getPropertyAnnotation ( \ ReflectionProperty $ property , $ annotationClass , AnnotationReader $ reader ) { return $ reader -> getPropertyAnnotation ( $ property , $ annotationClass ) ; }
|
Get Property Annotation
|
57,183
|
public static function getEventListener ( $ className , EntityManager $ manager ) { foreach ( $ manager -> getEventManager ( ) -> getListeners ( ) as $ listeners ) { foreach ( $ listeners as $ listener ) { if ( $ listener instanceof $ className ) { return $ listener ; } } } return null ; }
|
Get Event Listener
|
57,184
|
public static function hasPropertyAnnotation ( \ ReflectionProperty $ property , $ annotationClass , AnnotationReader $ reader ) { if ( null === self :: getPropertyAnnotation ( $ property , $ annotationClass , $ reader ) ) { return false ; } return true ; }
|
Has Property Annotation
|
57,185
|
public function setWebRootPath ( $ path ) { if ( @ file_exists ( $ path ) && is_dir ( $ path ) ) { $ this -> web_root_path = realpath ( $ path ) . '/' ; } else { throw new \ InvalidArgumentException ( sprintf ( 'Web root path "%s" was not found or is not a directory!' , $ path ) ) ; } return $ this ; }
|
Set the web root path
|
57,186
|
public function getTemplateObject ( $ _type , $ _ref = null ) { $ stack_name = ! is_null ( $ _ref ) ? $ _ref : $ this -> getTemplateObjectClassName ( $ _type ) ; if ( ! $ this -> registry -> isEntry ( $ stack_name , 'template_objects' ) ) { $ this -> createNewTemplateObject ( $ _type , $ _ref ) ; } return $ this -> registry -> getEntry ( $ stack_name , 'template_objects' ) ; }
|
Get a template object and create it if so
|
57,187
|
public function createNewTemplateObject ( $ _type , $ _ref = null ) { $ _cls = $ this -> getTemplateObjectClassName ( $ _type ) ; $ stack_name = ! is_null ( $ _ref ) ? $ _ref : $ _cls ; if ( class_exists ( $ _cls ) ) { try { $ _tpl_object = new $ _cls ( $ this ) ; } catch ( \ Exception $ e ) { throw new \ RuntimeException ( sprintf ( 'An error occurred while trying to create Template Object "%s"!' , $ _cls ) ) ; } if ( ! ( $ _tpl_object instanceof \ TemplateEngine \ TemplateObject \ Abstracts \ AbstractTemplateObject ) ) { throw new \ DomainException ( sprintf ( 'A Template Object must extends the "\TemplateEngine\TemplateObject\Abstracts\AbstractTemplateObject" class (got "%s")!' , $ _cls ) ) ; } else { $ this -> registry -> setEntry ( $ stack_name , $ _tpl_object , 'template_objects' ) ; } } else { throw new \ RuntimeException ( sprintf ( 'Template Object for type "%s" doesn\'t exist!' , $ _type ) ) ; } }
|
Create a new template object and reference it in the registry
|
57,188
|
public function findAsset ( $ file_path ) { $ real_path = $ this -> findRealPath ( $ file_path ) ; if ( $ real_path ) { return trim ( FilesystemHelper :: resolveRelatedPath ( $ this -> web_root_path , $ real_path ) , '/' ) ; } return null ; }
|
Find an asset file relative path web ready
|
57,189
|
public function findRealPath ( $ file_path ) { if ( @ file_exists ( $ file_path ) ) { return realpath ( $ file_path ) ; } if ( @ file_exists ( $ this -> web_root_path . $ file_path ) ) { return $ this -> web_root_path . $ file_path ; } return null ; }
|
Find a file absolute path in application
|
57,190
|
public function findByName ( $ name , array $ locations = [ ] ) { if ( empty ( $ locations ) ) { $ locations = $ this -> lookupPaths ; } $ finder = new Finder ; $ finder -> directories ( ) -> depth ( 0 ) -> name ( $ name ) -> in ( $ locations ) ; $ skeletons = iterator_to_array ( $ finder , true ) ; return reset ( $ skeletons ) ; }
|
Returns an array of found skeletons with that name in configured or given locations .
|
57,191
|
public function findAll ( array $ locations = [ ] ) { if ( empty ( $ locations ) ) { $ locations = $ this -> lookupPaths ; } $ finder = new Finder ; $ finder -> directories ( ) -> depth ( 0 ) -> sortByName ( ) -> in ( $ locations ) ; return iterator_to_array ( $ finder , true ) ; }
|
Returns an array of all found skeletons in the configured or given locations .
|
57,192
|
public function createFromComposerJson ( $ composer ) { $ sections = $ this -> getAutoloadSectionNames ( $ composer ) ; if ( empty ( $ sections ) ) { return array ( ) ; } $ validators = array ( ) ; foreach ( $ sections as $ section ) { $ validators [ ] = $ this -> createValidatorsFromSection ( $ section , $ composer [ $ section ] ) ; } return call_user_func_array ( 'array_merge' , $ validators ) ; }
|
Generate validators for all information from the passed composer . json array .
|
57,193
|
public function createValidator ( $ section , $ type , $ information ) { switch ( $ type ) { case 'classmap' : return new ClassMapValidator ( $ section . '.' . $ type , $ information , $ this -> baseDir , $ this -> generator , $ this -> report ) ; case 'files' : return new FilesValidator ( $ section . '.' . $ type , $ information , $ this -> baseDir , $ this -> generator , $ this -> report ) ; case 'psr-0' : return new Psr0Validator ( $ section . '.' . $ type , $ information , $ this -> baseDir , $ this -> generator , $ this -> report ) ; case 'psr-4' : return new Psr4Validator ( $ section . '.' . $ type , $ information , $ this -> baseDir , $ this -> generator , $ this -> report ) ; case 'exclude-from-classmap' : return null ; default : throw new \ InvalidArgumentException ( 'Unknown auto loader type ' . $ type . ' encountered!' ) ; } }
|
Create an validator .
|
57,194
|
private function getAutoloadSectionNames ( $ composer ) { $ sections = array ( ) ; if ( array_key_exists ( 'autoload' , $ composer ) ) { $ sections [ ] = 'autoload' ; } if ( array_key_exists ( 'autoload-dev' , $ composer ) ) { $ sections [ ] = 'autoload-dev' ; } return $ sections ; }
|
Ensure that a composer autoload section is present .
|
57,195
|
private function createValidatorsFromSection ( $ sectionName , $ section ) { $ validators = array ( ) ; foreach ( $ section as $ type => $ content ) { if ( $ validator = $ this -> createValidator ( $ sectionName , $ type , $ content ) ) { $ validators [ ] = $ validator ; } } return $ validators ; }
|
Create all validators for the passed section .
|
57,196
|
public function index ( $ id = 0 ) { $ post = $ this -> request -> _getPost ( ) ; $ buffers = [ ] ; foreach ( $ post as $ request ) { $ this -> prepareGetRequest ( $ request ) ; $ this -> controllerService -> callController ( $ request [ 'controller' ] , $ request [ 'method' ] , $ request [ 'id' ] , $ request [ 'params' ] ) ; $ buffer = $ this -> response -> getBuffer ( ) ; $ buffer [ 'requestid' ] = $ request [ 'requestid' ] ; $ buffers [ ] = $ buffer ; $ this -> response -> clear ( ) ; } $ this -> response -> setResponse ( 'Multiple' , $ buffers ) ; return true ; }
|
Dispatch all request
|
57,197
|
protected function formatBody ( $ value , array $ doc ) { $ value = $ this -> convertEncoding ( $ value ) ; $ value = mb_ereg_replace ( '<h[1-5].*?>(.*?)</h[1-5]>' , "<h3>\\1</h3>" , $ value ) ; $ value = str_replace ( '[jump]' , '<!-- [jump] , $ value ) ; $ value = mb_ereg_replace ( '<a\shref="\s+' , '<a href="' , $ value , 'i' ) ; $ value = mb_ereg_replace ( '<p[^>]*>[\s| ]*<\/p>' , '' , $ value , 'ims' ) ; $ value = $ this -> replaceEmDash ( $ value ) ; $ value = $ this -> transformOEmbeds ( $ value ) ; return trim ( $ value ) ; }
|
Performs specific body text formatting
|
57,198
|
protected function getFilePath ( $ type = 'image' , DateTime $ date = null ) { $ date = $ date ? : new DateTime ( ) ; return sprintf ( 'files/base/%s/%s/%s/%s/%s' , $ this -> getAccountKey ( ) , $ this -> getGroupKey ( ) , $ type , $ date -> format ( 'Y' ) , $ date -> format ( 'm' ) ) ; }
|
Returns a standard media path from supplied type and date .
|
57,199
|
final protected function getConfigValue ( $ path = null , $ returnValue = null ) { if ( null !== $ path ) { return $ this -> importer -> getPersister ( ) -> getConfigLoader ( ) -> getValues ( ) -> get ( $ path , $ returnValue ) ; } return $ this -> importer -> getPersister ( ) -> getConfigLoader ( ) -> getValues ( ) ; }
|
Gets a configuration value
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.