idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
56,000
private function getClientBrowser ( \ DeviceDetector \ DeviceDetector $ deviceDetectorClass , $ userAgent ) { $ this -> autoPopulateSuperGlobals ( ) ; $ browserInfoArray = [ 'architecture' => $ this -> getArchitectureFromUserAgent ( $ userAgent , 'browser' ) , 'connection' => $ this -> brServerGlobals -> server -> get ...
Provides details about browser
56,001
private function getClientBrowserAccepted ( ) { $ this -> autoPopulateSuperGlobals ( ) ; $ sReturn = [ 'accept' => $ this -> brServerGlobals -> server -> get ( 'HTTP_ACCEPT' ) , 'accept_encoding' => $ this -> brServerGlobals -> server -> get ( 'HTTP_ACCEPT_ENCODING' ) , ] ; if ( ! is_null ( $ this -> brServerGlobals ->...
Returns accepted things setting from the client browser
56,002
public function getClientBrowserDetails ( $ returnType = [ 'Browser' , 'Device' , 'OS' ] , $ tmpFolder = null ) { $ userAgent = $ this -> getUserAgentByCommonLib ( ) ; $ devDetectClass = new \ DeviceDetector \ DeviceDetector ( $ userAgent ) ; if ( is_null ( $ tmpFolder ) ) { $ tmpFolder = '../../tmp/DoctrineCache/' ; }...
Provides various details about browser based on user agent
56,003
private function getClientBrowserDevice ( \ DeviceDetector \ DeviceDetector $ deviceDetectorClass ) { $ this -> autoPopulateSuperGlobals ( ) ; $ clientIp = $ this -> brServerGlobals -> getClientIp ( ) ; return [ 'brand' => $ deviceDetectorClass -> getDeviceName ( ) , 'ip' => $ clientIp , 'ip direct' => $ this -> brServ...
Returns client device details from client browser
56,004
private function getClientBrowserOperatingSystem ( \ DeviceDetector \ DeviceDetector $ deviceDetectorClass , $ userAgent ) { $ aReturn = $ deviceDetectorClass -> getOs ( ) ; $ aReturn [ 'architecture' ] = $ this -> getArchitectureFromUserAgent ( $ userAgent , 'os' ) ; $ operatingSystem = new \ DeviceDetector \ Parser \...
Returns client operating system details from client browser
56,005
public function getUserAgentByCommonLib ( ) { $ this -> autoPopulateSuperGlobals ( ) ; if ( ! is_null ( $ this -> brServerGlobals -> get ( 'ua' ) ) ) { return $ this -> brServerGlobals -> get ( 'ua' ) ; } return $ this -> getUserAgentByCommonLibDetection ( ) ; }
Captures the user agent
56,006
public function viewAction ( ) { $ comments = new \ Phpmvc \ Comment \ CommentsInSession ( ) ; $ comments -> setDI ( $ this -> di ) ; $ all = $ comments -> findAll ( ) ; $ this -> views -> add ( 'comment/comments' , [ 'comments' => $ all , ] ) ; }
View all comments .
56,007
public function removeAllAction ( ) { $ isPosted = $ this -> request -> getPost ( 'doRemoveAll' ) ; if ( ! $ isPosted ) { $ this -> response -> redirect ( $ this -> request -> getPost ( 'redirect' ) ) ; } $ comments = new \ Phpmvc \ Comment \ CommentsInSession ( ) ; $ comments -> setDI ( $ this -> di ) ; $ comments -> ...
Remove all comments .
56,008
protected function addQueryString ( $ uri , array $ parameters ) { if ( ! is_null ( $ fragment = parse_url ( $ uri , PHP_URL_FRAGMENT ) ) ) { $ uri = preg_replace ( '/#.*/' , '' , $ uri ) ; } $ uri .= $ this -> getRouteQueryString ( $ parameters ) ; return is_null ( $ fragment ) ? $ uri : $ uri . "#{$fragment}" ; }
Add a query string to the URI .
56,009
protected function getRouteScheme ( $ route ) { if ( $ route -> httpOnly ( ) ) { return $ this -> getScheme ( false ) ; } elseif ( $ route -> httpsOnly ( ) ) { return $ this -> getScheme ( true ) ; } return $ this -> getScheme ( null ) ; }
Get the scheme for the given route .
56,010
public function isValidUrl ( $ path ) { if ( Str :: startsWith ( $ path , [ '#' , '//' , 'mailto:' , 'tel:' , 'http://' , 'https://' ] ) ) return true ; return filter_var ( $ path , FILTER_VALIDATE_URL ) !== false ; }
Determine if the given path is a valid URL .
56,011
protected function genNonce ( ) { $ chars = '1234567890abcdefghijklmnopqrstuvwxyz' ; $ rnd_string = '' ; $ num_chars = strlen ( $ chars ) ; $ size = mt_rand ( 41 , 59 ) ; for ( $ i = 0 ; $ i < $ size ; $ i ++ ) { $ rnd_string .= $ chars [ mt_rand ( 0 , $ num_chars - 1 ) ] ; } return $ rnd_string ; }
Generating a random string which will be used as nonce
56,012
protected function genHash ( $ data , $ nonce ) { $ token = $ this -> getConfig ( ) -> getStorage ( ) -> getAccessToken ( ) -> getAccessToken ( ) ; return sha1 ( urlencode ( $ data ) . $ this -> getConfig ( ) -> getAppId ( ) . urlencode ( sha1 ( $ token ) ) . urlencode ( $ nonce ) . $ this -> getConfig ( ) -> getAppSec...
Generating the required hash value from the data nonce and the other information that is nearly static
56,013
public function handle ( $ server , $ get , $ post ) { $ smalldb = null ; $ path = trim ( isset ( $ server [ 'PATH_INFO' ] ) ? $ server [ 'PATH_INFO' ] : '' , '/' ) ; $ path = ( $ path == '' ? array ( ) : explode ( '/' , $ path ) ) ; $ path_tail = end ( $ path ) ; if ( strpos ( $ path_tail , '!' ) !== FALSE ) { list ( ...
Interpret the HTTP request
56,014
public function compileSelect ( Builder $ query ) { $ this -> beforeGet ( $ query ) ; return $ this -> grammar -> compileSelect ( $ query ) ; }
Compile a select query into SQL
56,015
public function compileInsert ( Builder $ query , array $ values ) { foreach ( $ values as & $ row ) { $ this -> beforePut ( $ row ) ; } unset ( $ row ) ; $ this -> remapWheres ( $ query ) ; $ sql = $ this -> grammar -> compileInsert ( $ query , $ values ) ; if ( $ this -> replace_into ) { $ sql = preg_replace ( '/^ins...
Compile an insert statement into SQL
56,016
public function compileInsertGetId ( Builder $ query , $ values , $ sequence ) { $ this -> beforePut ( $ values ) ; $ this -> remapWheres ( $ query ) ; $ sql = $ this -> grammar -> compileInsertGetId ( $ query , $ values , $ sequence ) ; if ( $ this -> replace_into ) { $ sql = preg_replace ( '/^insert into/i' , 'replac...
Compile an insert and get ID statement into SQL
56,017
public function compileUpdate ( Builder $ query , $ values ) { $ this -> beforePut ( $ values ) ; $ this -> remapWheres ( $ query ) ; return $ this -> grammar -> compileUpdate ( $ query , $ values ) ; }
Compile an update statement into SQL
56,018
public function compileDelete ( Builder $ query ) { $ this -> remapWheres ( $ query ) ; return $ this -> grammar -> compileDelete ( $ query ) ; }
Compile a delete statement into SQL
56,019
private function registerEvents ( ) { foreach ( $ this -> getSetting ( 'events' , [ ] ) as $ event => $ listeners ) { foreach ( $ listeners as $ listener ) { Event :: bind ( $ event , $ listener ) ; } } }
Register custom events .
56,020
protected function resetBinds ( $ prefix = null ) { if ( $ prefix === null ) { $ this -> builder -> setParameters ( [ ] ) ; return ; } $ params = ( array ) $ this -> builder -> getParameters ( ) ; $ types = ( array ) $ this -> builder -> getParameterTypes ( ) ; foreach ( array_keys ( $ params ) as $ key ) { if ( strpos...
Removes bound values by their prefix If prefix is null - clears all bound values
56,021
protected function addFluentIndexes ( ) { foreach ( $ this -> columns as $ column ) { foreach ( [ 'primary' , 'unique' , 'index' ] as $ index ) { if ( $ column -> $ index === true ) { $ this -> $ index ( $ column -> name ) ; continue 2 ; } elseif ( isset ( $ column -> $ index ) ) { $ this -> $ index ( $ column -> name ...
Add the index commands fluently specified on columns .
56,022
public static function fromIdentifierOrAlias ( $ identifierOrAlias ) { $ alias = $ identifierOrAlias ; $ identifier = 'Plain' ; if ( isset ( self :: $ aliasToIdentifierMap [ $ identifierOrAlias ] ) ) { $ identifier = self :: $ aliasToIdentifierMap [ $ identifierOrAlias ] ; } return new static ( $ alias , $ identifier )...
Instantiates the brush by identifier or alias .
56,023
public static function permissions ( ) : array { $ permissions = parent :: permissions ( ) ; $ ci = & get_instance ( ) ; $ ci -> load -> model ( 'blog/blog_model' ) ; $ blogs = $ ci -> blog_model -> getAll ( ) ; $ out = array ( ) ; if ( ! empty ( $ blogs ) ) { foreach ( $ blogs as $ blog ) { $ permissions [ $ blog -> i...
Returns an array of permissions which can be configured for the user
56,024
static public function manufacture ( $ conn , Cache $ cache_driver , Reader $ annotation_reader , array $ entity_paths , $ autogenerate_strategy = false , $ ensure_production_settings = false , $ doctrine_annotations_file_path = self :: DOCTRINE_ANNOTATIONS_FILE_PATH , $ proxy_namespace = "Doctrine\\Proxies" , $ proxy_...
Manufactures an EntityManager instance using the passed configuration .
56,025
public function insertStmts ( array $ stmts , $ offset = 0 , $ remove = 0 ) { if ( false === $ offset ) { $ offset = count ( $ this -> stmts ) ; } elseif ( false === $ remove ) { $ remove = count ( $ this -> stmts ) ; } array_splice ( $ this -> stmts , $ offset , $ remove , $ stmts ) ; return $ this ; }
Insert or replace some statements .
56,026
public function getItems ( ) { $ res = array ( ) ; foreach ( $ this -> iter as $ item ) { if ( count ( $ res ) == 10 ) break ; $ res [ ] = $ item -> CloneInstance ( ) ; } return $ res ; }
Return the first 10 items of the iterator
56,027
public function findBy ( $ field , $ value ) { $ model_class = $ this -> getModelName ( ) ; return $ model_class :: where ( $ field , $ value ) -> first ( ) ; }
Find a record by a custom field
56,028
public function create ( array $ data ) : Model { $ model_class = $ this -> getModelName ( ) ; return $ this -> postCreate ( $ data , $ model_class :: create ( $ this -> preCreate ( $ this -> parseData ( $ data ) ) ) ) ; }
Create and return the model object
56,029
public function delete ( $ id ) { if ( $ record = $ this -> find ( $ id ) ) { if ( $ this -> preDelete ( $ id , $ record ) ) { return $ this -> postDelete ( $ id , $ record -> delete ( ) , $ record ) ; } } else { $ this -> throwModelNotFoundException ( $ id ) ; } }
Delete a record by ID
56,030
public function parseData ( array $ data ) : array { if ( $ this -> getTransformer ( ) instanceof RequestTransformerContract ) { return $ this -> getTransformer ( ) -> transformRequestData ( $ data ) ; } return $ data ; }
Parse the data using the request method of the transformer if it exists
56,031
public function transformItem ( Model $ item , $ includes = [ ] , TransformerContract $ transformer = null ) { $ this -> fractal_manager -> parseIncludes ( $ includes ) ; $ transformer = is_null ( $ transformer ) ? $ this -> getTransformer ( ) : $ transformer ; $ resource = new Item ( $ item , $ transformer , $ this ->...
Pass a model through the transformer
56,032
public function newQuery ( ) : QueryBuilder { $ model = $ this -> container -> make ( $ this -> getModelName ( ) ) ; if ( ! $ model instanceof Model ) { throw new RepositoryException ( "Class {$this->model()} must be an instance of " . Model :: class ) ; } return $ model -> newQuery ( ) ; }
Create a new query instance
56,033
protected function throwModelNotFoundException ( $ id ) { throw new ModelNotFoundException ( 'Model not found for ID ' . $ id . ' on table ' . $ this -> container -> make ( $ this -> getModelName ( ) ) -> getTable ( ) ) ; }
Throw an exception when a model is not found
56,034
public function parent ( ) { return $ this -> filter ( [ 'lft__lt' => $ this -> getModel ( ) -> lft , 'rgt__gt' => $ this -> getModel ( ) -> rgt , 'level' => $ this -> getModel ( ) -> level - 1 , 'root' => $ this -> getModel ( ) -> root , ] ) ; }
Named scope . Gets parent of node .
56,035
protected function rebuildLftRgt ( string $ table ) { $ builder = QueryBuilderFactory :: getQueryBuilder ( $ this -> getConnection ( ) ) ; $ subQuerySql = ( clone $ builder ) -> clear ( ) -> select ( 'tt.parent_id' ) -> table ( $ table , 'tt' ) -> where ( 'tt.parent_id=t.id' ) -> toSQL ( ) ; $ sql = ( clone $ builder )...
Find and delete broken branches without root parent and with incorrect lft rgt .
56,036
public function toHierarchy ( $ collection ) : array { $ trees = [ ] ; if ( count ( $ collection ) > 0 ) { $ stack = [ ] ; foreach ( $ collection as $ item ) { $ item [ $ this -> treeKey ] = [ ] ; $ l = count ( $ stack ) ; while ( $ l > 0 && $ stack [ $ l - 1 ] [ 'level' ] >= $ item [ 'level' ] ) { array_pop ( $ stack ...
Make hierarchy array by level .
56,037
public static function writable ( $ path ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( ! self :: exist ( $ path ) ) { return false ; } return ( is_dir ( $ path ) && is_writable ( $ path ) ) ; }
Check if directory is writable
56,038
public static function create ( $ path , $ chmod = 0755 ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( self :: exist ( $ path ) ) { return false ; } return @ mkdir ( $ path , $ chmod , true ) ; }
Create directory with recursive support .
56,039
public static function remove ( $ path ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( ! self :: exist ( $ path ) ) { return false ; } foreach ( new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ path , FilesystemIterator :: SKIP_DOTS ) , RecursiveIteratorIterator :: CHILD_FIRST ) as $ dir ) { ...
Remove directory recursive .
56,040
public static function scan ( $ path , $ mod = GLOB_ONLYDIR , $ returnRelative = false ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( ! self :: exist ( $ path ) ) { return false ; } $ pattern = rtrim ( $ path , '/' ) . '/*' ; $ entry = glob ( $ pattern , $ mod ) ; if ( $ returnRelative === true ) { foreach ( ...
Scan files in directory and return full or relative path
56,041
public static function recursiveChmod ( $ path , $ mod = 0777 ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( ! self :: exist ( $ path ) ) { return ; } $ dir = new \ DirectoryIterator ( $ path ) ; foreach ( $ dir as $ item ) { if ( $ item -> isDir ( ) || $ item -> isFile ( ) ) { chmod ( $ item -> getPathname (...
Change chmod recursive inside defined folder
56,042
public function getContent ( ) { $ json = new \ stdClass ( ) ; $ json -> isSuccess = $ this -> isSuccess ( ) ; $ json -> errorCode = $ this -> getErrorCode ( ) ; $ json -> errorMessage = $ this -> getErrorMessage ( ) ; $ json -> data = $ this -> content ; return $ json ; }
Over getContent response . Add specific content to the response .
56,043
final public function setErrorMessage ( $ message ) { $ this -> errorMessage = ( string ) $ message ; if ( empty ( $ this -> errorMessage ) ) { throw new \ RuntimeException ( 'Error message cannot be empty !' ) ; } return $ this ; }
Set error message .
56,044
public function appendContent ( $ key , $ value ) { if ( $ this -> content === null ) { $ this -> content = array ( ) ; } if ( ! is_array ( $ this -> content ) ) { throw new \ InvalidArgumentException ( 'Cannot append response content: Current content is not an array !' ) ; } $ this -> content [ ( string ) $ key ] = $ ...
Append content for the response .
56,045
public function get ( $ route_name ) { $ route = null ; if ( ! array_key_exists ( $ route_name , $ this -> routes ) ) echo "Router: error: the array key $route_name doesn't exists.<br />" ; else { $ route_infos = $ this -> routes [ $ route_name ] ; if ( $ route_controller = $ this -> instancy_controller ( $ route_infos...
returns the controller with route_name
56,046
public function check ( $ getPayload = false ) { try { $ payload = $ this -> checkOrFail ( ) ; } catch ( JwTException $ e ) { return false ; } return $ getPayload ? $ payload : true ; }
Check that the token is valid .
56,047
public function has ( string $ key ) : bool { foreach ( $ this -> repositories as $ repository ) { if ( $ repository -> has ( $ key ) ) { return true ; } } return false ; }
Check whether the repository contains a given key .
56,048
public function isValidResponse ( $ ha1 ) { if ( $ this -> opaque === NULL ) { return false ; } if ( ! SecurityUtil :: timingSafeEquals ( $ this -> auth -> getOpaque ( ) , $ this -> opaque ) ) { return false ; } $ args = [ $ ha1 , $ this -> nonce , $ this -> nc , $ this -> cnonce , $ this -> auth -> getQualityOfProtect...
Check if the response is valid using the given HA1 value .
56,049
public function addRoute ( string $ path , string $ controller , string $ action = 'index' , string $ method = Request :: METHOD_GET ) : self { $ endPoint = new RouteEndpoint ( $ this -> namespace , $ controller , $ action , $ method ) ; $ this -> routes [ ] = new Route ( $ path , $ endPoint ) ; return $ this ; }
Add a new route to the collection
56,050
public function defaultSpa ( $ request , $ match ) { $ name = Tenant_Service :: setting ( 'spa.default' , 'not-found' ) ; $ spa = Tenant_SPA :: getSpaByName ( $ name ) ; if ( ! isset ( $ spa ) ) { $ spa = Tenant_SpaService :: getNotfoundSpa ( ) ; } $ host = ( $ request -> https ? 'https://' : 'http://' ) . $ request ->...
Load default spa
56,051
public function defaultSpaRobotsTxt ( $ request , $ match ) { $ name = Tenant_Service :: setting ( 'spa.default' , 'not-found' ) ; $ spa = Tenant_SPA :: getSpaByName ( $ name ) ; if ( ! isset ( $ spa ) ) { $ spa = Tenant_SpaService :: getNotfoundSpa ( ) ; } $ resourcePath = $ spa -> getResourcePath ( 'robots.txt' ) ; $...
Load robots . txt of default spa
56,052
public function loadResource ( $ request , $ match ) { $ firstPart = $ match [ 'firstPart' ] ; $ remainPart = '' ; if ( array_key_exists ( 'remainPart' , $ match ) ) { $ remainPart = $ match [ 'remainPart' ] ; } $ spa = Tenant_SPA :: getSpaByName ( $ firstPart ) ; if ( isset ( $ spa ) ) { $ path = $ remainPart ; $ spaN...
Load a resource from SPA
56,053
private function findTenantResource ( $ path ) { $ q = new Pluf_SQL ( 'path=%s' , array ( $ path ) ) ; $ item = new Tenant_Resource ( ) ; $ item = $ item -> getList ( array ( 'filter' => $ q -> gen ( ) ) ) ; if ( isset ( $ item ) && $ item -> count ( ) == 1 ) { return $ item [ 0 ] ; } return null ; }
Finds tenant resource with path
56,054
public function transpile ( ) { $ this -> form = $ this -> transpiler -> instantiateFormObject ( ) ; $ fields = $ this -> transpiler -> findFields ( ) ; if ( ! is_array ( $ fields ) ) { throw new \ Exception ( "No fields found" ) ; } $ this -> form -> addFields ( $ fields ) ; $ this -> form -> populateFields ( ) ; $ th...
Convert a markup to a BaseForm objet
56,055
function ruleBefore ( $ date , $ error_message = null ) { if ( ! strtotime ( $ date ) ) { throw new \ Exception ( 'Incorrect date' ) ; } return $ this -> _rule ( 'before:' . $ date , $ error_message ) ; }
The field under validation must be a value preceding the given date . The dates will be passed into the PHP strtotime function .
56,056
function ruleBetween ( $ min , $ max , $ error_message = null ) { if ( ! is_numeric ( $ min ) ) { throw new \ Exception ( 'Incorrect parameter MIN in rule between' ) ; } if ( ! is_numeric ( $ max ) ) { throw new \ Exception ( 'Incorrect parameter MAX in rule between' ) ; } return $ this -> _rule ( 'between:' . $ min . ...
The field under validation must have a size between the given min and max . Strings numerics and files are evaluated in the same fashion as the size rule .
56,057
function ruleMin ( $ min , $ error_message = null ) { if ( ! is_numeric ( $ min ) ) { throw new \ Exception ( 'Incorrect parameter MIN in rule min' ) ; } return $ this -> _rule ( 'min:' . $ min , $ error_message ) ; }
The field under validation must have a minimum value . Strings numerics and files are evaluated in the same fashion as the size rule .
56,058
function ruleRequiredIf ( $ anotherfield , $ value , $ error_message = null ) { return $ this -> _rule ( 'required_if:' . $ anotherfield . ',' . $ value , $ error_message ) ; }
The field under validation must be present if the anotherfield field is equal to any value .
56,059
function ruleRequiredUnless ( $ anotherfield , $ value , $ error_message = null ) { return $ this -> _rule ( 'required_unless:' . $ anotherfield . ',' . $ value , $ error_message ) ; }
The field under validation must be present unless the anotherfield field is equal to any value .
56,060
function ruleRequiredWith ( $ anotherfields , $ error_message = null ) { if ( is_array ( $ anotherfields ) ) { $ anotherfields = implode ( ',' , $ anotherfields ) ; } return $ this -> _rule ( 'required_with:' . $ anotherfields , $ error_message ) ; }
The field under validation must be present only if any of the other specified fields are present .
56,061
function ruleRequiredWithout ( $ anotherfields , $ error_message = null ) { if ( is_array ( $ anotherfields ) ) { $ anotherfields = implode ( ',' , $ anotherfields ) ; } return $ this -> _rule ( 'required_without:' . $ anotherfields , $ error_message ) ; }
The field under validation must be present only when any of the other specified fields are not present .
56,062
function ruleRequiredWithoutAll ( $ anotherfields , $ error_message = null ) { if ( is_array ( $ anotherfields ) ) { $ anotherfields = implode ( ',' , $ anotherfields ) ; } return $ this -> _rule ( 'required_without_all:' . $ anotherfields , $ error_message ) ; }
The field under validation must be present only when all of the other specified fields are not present .
56,063
protected function copyAndNormalize ( ) { if ( $ this -> utcTimezone === null ) $ this -> utcTimezone = new DateTimeZone ( 'UTC' ) ; $ args = func_get_args ( ) ; foreach ( $ args as $ i => $ dt ) if ( $ dt instanceof DateTime ) { $ dt = clone $ dt ; $ dt -> setTimezone ( $ this -> utcTimezone ) ; $ args [ $ i ] = $ dt ...
Copies any number of DateTime objects and normalizes their timezones .
56,064
public function log ( $ level , $ message , array $ context = [ ] ) { if ( array_key_exists ( $ level , $ this -> logPrefixesPerLevel ) === false ) { throw new InvalidArgumentException ( 'Console method not recognised' ) ; } $ parsedMessage = $ this -> parseMessage ( $ message ) ; $ parsedMessage .= $ this -> parseCont...
Logs to an arbitrary log level .
56,065
private function parseMessage ( $ message ) { $ parsedMessage = null ; switch ( gettype ( $ message ) ) { case 'boolean' : case 'integer' : case 'double' : case 'string' : case 'NULL' : $ parsedMessage = ( string ) $ message ; break ; case 'object' : if ( method_exists ( $ message , '__toString' ) !== false ) { $ parse...
Parses the log message and returns as a useable string or Psr \ Log \ InvalidArgumentException if non parseable .
56,066
public function parse ( array $ classes ) { $ APIAnnotations = [ ] ; foreach ( $ classes as $ class ) { $ reflectionClass = new \ ReflectionClass ( $ class ) ; foreach ( $ reflectionClass -> getMethods ( ) as $ reflectionMethod ) { $ annotations = $ this -> getReader ( ) -> getMethodAnnotations ( $ reflectionMethod ) ;...
Parses the files provided by the SeekableIterator
56,067
protected static function extractType ( $ type ) { if ( substr ( $ type , - 2 ) === Connection :: PARAM_ARRAY ) { return substr ( $ type , 0 , strlen ( $ type ) - 2 ) ; } return false ; }
Extracts the fridge type from the expanded type .
56,068
public static function autoload ( ) { $ dir_base = realpath ( __DIR__ . '/../../../../' ) ; $ finder = new Finder ( ) ; $ finder -> files ( ) -> ignoreVCS ( true ) -> ignoreDotFiles ( false ) -> name ( 'service.yml' ) -> exclude ( 'Tests' ) -> exclude ( 'tests' ) -> in ( $ dir_base ) ; foreach ( $ finder as $ file ) { ...
Auto register services .
56,069
protected static function autoloadFile ( SplFileInfo $ file ) { $ yml = Yaml :: parse ( file_get_contents ( $ file -> getRealPath ( ) ) , true ) ; $ service = Arr :: get ( $ yml , 'micro-service' ) ; if ( is_null ( $ service ) ) { return ; } sbox ( ) -> add ( new MicroService ( $ service , $ yml ) ) ; }
Carregar arquivo .
56,070
protected function checkForMorePages ( ) { $ this -> hasMore = count ( $ this -> items ) > ( $ this -> perPage ) ; $ this -> items = $ this -> items -> slice ( 0 , $ this -> perPage ) ; }
Check for more pages . The last item will be sliced off .
56,071
public static function getMemberValueArrayForObjects ( $ member , $ objects ) { $ returnValues = array ( ) ; foreach ( $ objects as $ key => $ value ) { if ( is_object ( $ value ) ) { if ( $ value instanceof SerialisableObject ) { $ returnValues [ $ key ] = $ value -> __getSerialisablePropertyValue ( $ member ) ; } els...
Get an array of member values for a given member for the array of objects passed using the same indexing system as the passed objects .
56,072
public static function indexArrayOfObjectsByMember ( $ member , $ objects ) { $ returnValues = array ( ) ; foreach ( $ objects as $ object ) { if ( $ object instanceof SerialisableObject ) { $ returnValues [ $ object -> __getSerialisablePropertyValue ( $ member ) ] = $ object ; } else { throw new ClassNotSerialisableEx...
Index the array of passed objects by the supplied member returning an associative array .
56,073
public static function filterArrayOfObjectsByMember ( $ member , $ objects , $ filterValue ) { $ filterValues = is_array ( $ filterValue ) ? $ filterValue : array ( $ filterValue ) ; $ filteredObjects = array ( ) ; foreach ( $ objects as $ object ) { if ( $ object instanceof SerialisableObject ) { foreach ( $ filterVal...
Filter an array of objects by a specified member . Perhaps in the future extend to multiple match types .
56,074
public static function groupArrayOfObjectsByMember ( $ member , $ objects ) { if ( ! is_array ( $ member ) ) $ member = array ( $ member ) ; $ leafMember = array_pop ( $ member ) ; $ groupedObjects = new AssociativeArray ( ) ; foreach ( $ objects as $ object ) { $ rootNode = $ groupedObjects ; foreach ( $ member as $ m...
Group an array of objects by a given member .
56,075
private function saveFile ( ) { $ dirMedia = $ this -> filesystem -> getDirectoryWrite ( ADirList :: MEDIA ) ; $ dirTarget = $ dirMedia -> getAbsolutePath ( self :: MEDIA_SUBFOLDER ) ; $ fileId = self :: FIELDSET . '[' . self :: FIELD_CSV_FILE . ']' ; $ uploader = $ this -> factUploader -> create ( [ 'fileId' => $ file...
Save uploading file to the media folder
56,076
public function getBackendLayoutForPage ( int $ uid ) { $ rootLine = $ this -> pageRepository -> getRootLine ( $ uid ) ; if ( $ rootLine ) { $ index = - 1 ; foreach ( $ rootLine as $ page ) { $ index ++ ; $ backendLayout = $ page [ 'backend_layout' ] ; $ hasBackendLayout = false ; $ backendLayoutNextLevel = $ page [ 'b...
Gets the backend layout for a page .
56,077
public function generateThumbUrl ( MediaInterface $ media ) { $ path = null ; if ( $ media -> getType ( ) === MediaTypes :: IMAGE ) { $ path = $ this -> cacheManager -> getBrowserPath ( $ media -> getPath ( ) , 'media_thumb' ) ; } else { $ path = $ this -> generateFileThumb ( $ media ) ; } if ( null === $ path ) { $ pa...
Generates a thumb for the given media .
56,078
public function generateFrontUrl ( MediaInterface $ media ) { $ path = null ; if ( $ media -> getType ( ) === MediaTypes :: IMAGE ) { $ path = $ this -> cacheManager -> getBrowserPath ( $ media -> getPath ( ) , 'media_front' ) ; } elseif ( in_array ( $ media -> getType ( ) , [ MediaTypes :: VIDEO , MediaTypes :: AUDIO ...
Generates the default front url .
56,079
private function generateFileThumb ( MediaInterface $ media ) { $ extension = $ media -> guessExtension ( ) ; $ thumbPath = sprintf ( '/%s/%s.jpg' , $ this -> thumbsDirectory , $ extension ) ; $ destination = $ this -> webRootDirectory . $ thumbPath ; if ( file_exists ( $ destination ) ) { return $ thumbPath ; } $ back...
Generates thumb for non - image elements .
56,080
private function checkDir ( $ dir ) { if ( ! $ this -> fs -> exists ( $ dir ) ) { $ this -> fs -> mkdir ( $ dir ) ; } }
Creates the directory if it does not exists .
56,081
public function splitIsbn ( $ isbn ) { if ( ! $ this -> validateIsbn ( $ isbn ) ) { return false ; } $ prefix = substr ( $ isbn , 0 , 3 ) ; $ groupnumber = $ this -> getGroupNumber ( $ isbn ) ; $ pubnumber = $ this -> getPublisherNumber ( $ isbn ) ; $ prenumbers = strlen ( $ groupnumber ) + strlen ( $ pubnumber ) + 3 ;...
Splits a valid ISBN - 13 Number in its components
56,082
public function validateIsbn ( $ check ) { $ ean = strval ( $ check ) ; $ code = substr ( $ ean , 0 , - 1 ) ; $ key = $ this -> calculateCheckdigit13 ( $ code ) ; $ code .= $ key ; if ( $ code == $ ean ) { return true ; } else { return false ; } }
Validates an ISBN - 13 Number
56,083
public function init ( $ config = [ ] ) { if ( isset ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) ) { $ this -> userAgent = $ _SERVER [ 'HTTP_USER_AGENT' ] ; } if ( isset ( $ _SERVER [ 'SERVER_NAME' ] ) ) { $ this -> server = $ _SERVER [ 'SERVER_NAME' ] ; } if ( isset ( $ _SERVER [ 'SERVER_PORT' ] ) ) { $ this -> port = $ _SERV...
Initialises the request .
56,084
public function createUrl ( $ route , $ params = [ ] , $ absolute = FALSE ) { $ url = $ this -> script . '/' . $ route ; if ( file_exists ( TEST_LOCK_FILE ) ) { $ url = $ route ; } if ( ! empty ( $ params ) ) { foreach ( $ params as $ value ) { $ url .= "/$value" ; } } if ( $ absolute ) { if ( ! file_exists ( TEST_LOCK...
Creates a http url .
56,085
public function handleDatasource ( $ name , $ method , array $ preloadedData , array & $ templateVariables ) { $ this -> name = $ name ; $ datasource = ActionUtils :: createActionDatasource ( $ name , $ method ) ; $ this -> templateVars = & $ templateVariables ; $ this -> currentDatasource = $ datasource ; $ this -> cu...
this is used by the RenderModule when loading data from an element
56,086
protected function getTemplateVariable ( $ name , $ default = null ) { return array_key_exists ( $ name , $ this -> templateVars ) ? $ this -> templateVars [ $ name ] : $ default ; }
Used in datasource methods
56,087
protected function getRequiredTemplateVariable ( $ name ) { if ( ! array_key_exists ( $ name , $ this -> templateVars ) ) throw new ControllerException ( 'Required template variable [' . $ name . '] is missing' ) ; return $ this -> templateVars [ $ name ] ; }
Used in datasource methods throws ControllerException when value is missing
56,088
public function get ( $ type = 'success' ) { $ key = self :: BANDAMA_FLASH_KEY . '_' . $ type ; $ flash = $ this -> session -> get ( $ key ) ; $ this -> session -> delete ( $ key ) ; return $ flash ; }
Get flash message
56,089
public function getClient ( ) { if ( ! $ this -> client instanceof Client ) { $ this -> client = new Client ( [ "cookies" => true ] ) ; } return $ this -> client ; }
Returns the Client instance
56,090
protected function request ( $ method , $ url , $ options = [ ] ) { $ client = $ this -> getClient ( ) ; try { $ response = $ client -> request ( $ method , $ url , $ options ) ; } catch ( \ GuzzleHttp \ Exception \ ClientException $ e ) { $ response = $ e -> getResponse ( ) ; throw new PeopleMatterException ( $ respon...
Executes a request to the PeopleMatter API
56,091
final protected function applyOperator ( \ SelectQueryInterface $ query , $ statement , $ value ) { if ( is_array ( $ value ) && ! Misc :: isIndexed ( $ value ) ) { $ keys = array_keys ( $ value ) ; $ operator = $ keys [ 0 ] ; $ value = $ value [ $ operator ] ; switch ( $ operator ) { case '<>' : if ( is_array ( $ valu...
Apply the operator onto the query
56,092
public function attach ( Base $ entity , & $ restingPlace = null ) { if ( ! $ this -> makeableSafetyCheck ( ) ) { return null ; } if ( ! is_a ( $ entity , $ this -> entityClass ) ) { throw new EntityNotCompatibleWithRepositoryException ( $ entity , $ this ) ; } if ( $ key = $ entity -> keyGet ( $ entity ) ) { if ( isse...
Add a entity into the multiton array
56,093
public function isAttached ( Base $ entity ) { return false !== array_search ( $ entity , $ this -> instancesPersisted , true ) || false !== array_search ( $ entity , $ this -> instancesUnpersisted , true ) ; }
Is in multiton store .
56,094
public function detach ( Base $ entity , & $ detachedFrom = null ) { $ detachedFrom = null ; foreach ( array ( 'Persisted' , 'Unpersisted' ) as $ type ) { $ cache = "instances{$type}" ; $ cache = & $ this -> $ cache ; if ( false !== $ key = array_search ( $ entity , $ cache , true ) ) { unset ( $ cache [ $ key ] ) ; $ ...
Detach a entity from the multiton
56,095
public function rekey ( Base $ entity ) { if ( false !== $ key = array_search ( $ entity , $ this -> instancesPersisted , true ) ) { $ newKey = $ entity -> keyGet ( $ entity ) ; if ( isset ( $ this -> instancesPersisted [ $ newKey ] ) and $ entity !== $ this -> instancesPersisted [ $ newKey ] ) { throw new \ RuntimeExc...
A entity s key has changed . If it is in the repository this ll need rekeying
56,096
public function find ( $ key , $ disableLateLoading = null , $ cache = true ) { if ( ! is_bool ( $ disableLateLoading ) ) { $ disableLateLoading = false ; } if ( ! $ cache ) { return parent :: find ( $ key , $ disableLateLoading ) ; } if ( is_null ( $ key ) ) { return null ; } elseif ( is_scalar ( $ key ) ) { $ multito...
Multiton . Fuck yeah!
56,097
public function make ( array $ data = null ) { $ obj = parent :: make ( $ data ) ; $ this -> instancesUnpersisted [ ] = $ obj ; return $ obj ; }
Make a new entity
56,098
public function initByData ( array $ data = null ) { if ( ! $ data ) { return null ; } $ key = call_user_func ( array ( $ this -> entityClass , 'keyGet' ) , $ data ) ; if ( isset ( $ this -> instancesPersisted [ $ key ] ) ) { $ obj = $ this -> instancesPersisted [ $ key ] ; $ obj -> __construct ( $ data ) ; return $ ob...
Entry point for objects where you ve got the data array and you wish to instantiate a object and add to the cache .
56,099
public function isCached ( Base $ entity , $ source = self :: PERSISTED ) { switch ( $ source ) { case self :: PERSISTED : return false !== array_search ( $ entity , $ this -> instancesPersisted , true ) ; case self :: UNPERSISTED : return false !== array_search ( $ entity , $ this -> instancesUnpersisted , true ) ; ca...
Is this object in the multiton cache