idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
55,200
protected function compileSubQuery ( $ subQuery , array & $ bindings , bool $ parenthesise = true ) : string { if ( $ subQuery instanceof Query ) { try { $ subQuery = $ this -> compile ( $ subQuery ) ; } catch ( InvalidQueryException $ exception ) { throw new InvalidQueryException ( 'Error in subquery: ' . $ exception ...
Converts a subquery to an SQL query text .
55,201
protected function compileAggregate ( Aggregate $ aggregate , array & $ bindings ) : string { return $ aggregate -> function . '(' . $ this -> compileIdentifier ( $ aggregate -> column , $ bindings ) . ')' ; }
Converts an Aggregate object to an SQL query text .
55,202
protected function compileOneJoin ( Join $ join , array & $ bindings ) : string { $ sql = $ join -> type . ' JOIN ' . $ this -> compileIdentifierWithAlias ( $ join -> table , $ join -> tableAlias , $ bindings ) ; if ( $ join -> criteria ) { $ sql .= ' ON ' . $ this -> compileCriteria ( $ join -> criteria , $ bindings )...
Converts a Join object ot an SQL query text .
55,203
protected function compileOneOrder ( $ order , array & $ bindings ) : string { if ( $ order instanceof Order ) { return $ this -> compileIdentifier ( $ order -> column , $ bindings ) . ' ' . ( $ order -> isDescending ? 'DESC' : 'ASC' ) ; } if ( $ order instanceof OrderByIsNull ) { return $ this -> compileIdentifier ( $...
Converts a single order to an SQL query text .
55,204
protected function compileInsertFromValues ( $ table , string $ tableAlias = null , array $ values ) : array { if ( empty ( $ values ) ) { return [ ] ; } $ bindings = [ ] ; $ columns = [ ] ; foreach ( $ values as $ row ) { foreach ( $ row as $ column => $ value ) { if ( ! isset ( $ columns [ $ column ] ) ) { $ columns ...
Compiles set of full INSERT queries from an array of values .
55,205
protected function compileInsertFromSelect ( $ table , string $ tableAlias = null , array $ columns = null , $ selectQuery ) : StatementInterface { $ bindings = [ ] ; $ sqlLine1 = 'INSERT INTO ' . $ this -> compileIdentifierWithAlias ( $ table , $ tableAlias , $ bindings ) ; if ( $ columns !== null ) { $ sqlLine1 .= ' ...
Compiles a full INSERT query from a select query .
55,206
protected function mergeBindings ( array & $ target , array $ source ) { $ targetBindingsAmount = count ( $ target ) ; $ sourceBindingsIndex = 0 ; foreach ( $ source as $ name => $ value ) { $ key = is_int ( $ name ) ? $ targetBindingsAmount + $ sourceBindingsIndex : $ name ; $ target [ $ key ] = $ value ; $ sourceBind...
Merges two arrays of bound values .
55,207
protected function implodeSQL ( array $ parts ) : string { $ result = '' ; foreach ( $ parts as $ part ) { if ( $ part === '' ) { continue ; } $ result .= ( $ result === '' ? '' : "\n" ) . $ part ; } return $ result ; }
Implodes parts of SQL query to a single string .
55,208
public function registerRoutes ( ) { $ this -> _route = new Route ( ) ; $ this -> _config = Config :: from ( 'app' ) ; $ router = $ this ; require_once $ this -> _config -> from ( 'app' ) -> get ( 'routes' ) ; }
Handles registering defined routes .
55,209
public function getRoute ( $ url ) { $ routes = $ this -> _route -> getRoutes ( ) ; $ return = '' ; foreach ( $ routes as $ route ) { $ routeURI = $ this -> _config -> from ( 'app' ) -> get ( 'basepath' ) . $ route [ 'uri' ] ; if ( isset ( $ _POST ) ) { foreach ( $ _POST as $ key => $ value ) { $ route [ 'query' ] [ ] ...
Gets the route from supplied URL .
55,210
public function round ( $ decimals = 2 ) { if ( false === ( '-' . intval ( $ decimals ) == '-' . $ decimals ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type integer, "%s" given' , __METHOD__ , gettype ( $ decimals ) ) , E_USER_ERROR ) ; } return $ this -> convert ( function ( $ numb...
Round all the numbers with a precision
55,211
public function toFixed ( $ decimals = 2 ) { if ( false === ( '-' . intval ( $ decimals ) == '-' . $ decimals ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type integer, "%s" given' , __METHOD__ , gettype ( $ decimals ) ) , E_USER_ERROR ) ; } return $ this -> convert ( function ( $ nu...
Converts number into a string keeping a specified number of decimal
55,212
public function val ( $ index = 0 ) { if ( false === ( '-' . intval ( $ index ) == '-' . $ index ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type integer, "%s" given' , __METHOD__ , gettype ( $ index ) ) , E_USER_ERROR ) ; } $ val = $ this -> strip ( ) ; if ( true === isset ( $ val ...
Strips all the numbers from a string and returns the value with an optional index to retrieve
55,213
public function format ( $ decimals = 2 , $ point = '.' , $ thousands_sep = ',' , $ currency = null ) { if ( false === ( '-' . intval ( $ decimals ) == '-' . $ decimals ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type integer, "%s" given' , __METHOD__ , gettype ( $ decimals ) ) , E_...
Converts all the numbers in a string to a specific format
55,214
private function convert ( $ callback , $ variables = [ ] ) { $ this -> number = preg_replace_callback ( '~[0-9\.,]+~' , function ( $ number ) use ( $ callback , $ variables ) { return call_user_func_array ( $ callback , array_merge ( [ ( float ) str_replace ( ',' , '' , $ number [ 0 ] ) ] , $ variables ) ) ; } , $ thi...
Executes a callable function and returns this instance
55,215
public function addData ( array $ data , string $ type = "all" ) : self { $ this -> viewData [ $ type ] = array_merge ( $ this -> viewData [ $ type ] ?? [ ] , $ data ) ; return $ this ; }
Add view data
55,216
public function loadController ( $ module , $ controller ) { if ( false === is_string ( $ module ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ module ) ) , E_USER_ERROR ) ; } if ( false === is_string ( $ controller ) ) { return trigg...
Loads controller by module name and controller name
55,217
private function executeController ( $ controller , Route $ method , $ matches ) { if ( false === is_object ( $ controller ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type object, "%s" given' , __METHOD__ , gettype ( $ controller ) ) , E_USER_ERROR ) ; } if ( false === is_array ( $ ...
Executes default controller functions
55,218
private function loadBoot ( $ module ) { if ( false === is_string ( $ module ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ module ) ) , E_USER_ERROR ) ; } $ boot = Path :: get ( 'modules' ) . $ module . DIRECTORY_SEPARATOR . Files ::...
Load the module boot file if exists and readable
55,219
public static function specifyType ( $ domain ) { if ( false !== filter_var ( $ domain , FILTER_VALIDATE_IP ) ) { return new IPAddress ( $ domain ) ; } return new Hostname ( $ domain ) ; }
Returns a Hostname or a IPAddress object depending on passed value
55,220
function result ( $ _top = '' ) { ob_start ( ) ; $ this -> output ( $ _top ) ; $ result = ob_get_contents ( ) ; ob_end_clean ( ) ; return $ result ; }
Parser Wrapper Returns Template Output as a String
55,221
function output ( $ _top = '' ) { global $ _top ; if ( strlen ( $ this -> template_dir ) && substr ( $ this -> template_dir , - 1 ) != '/' ) { $ this -> template_dir .= '/' ; } if ( strlen ( $ this -> temp_dir ) && substr ( $ this -> temp_dir , - 1 ) != '/' ) { $ this -> temp_dir .= '/' ; } if ( ! is_array ( $ _top ) )...
Execute parsed Template Prints Parsing Results to Standard Output
55,222
function use_cache ( $ key = '' ) { if ( empty ( $ _POST ) ) { $ this -> cache_filename = $ this -> cache_dir . 'cache_' . md5 ( $ _SERVER [ 'REQUEST_URI' ] . serialize ( $ key ) ) . '.ser' ; if ( ( $ _SERVER [ 'HTTP_CACHE_CONTROL' ] != 'no-cache' ) && ( $ _SERVER [ 'HTTP_PRAGMA' ] != 'no-cache' ) && @ is_file ( $ this...
Start Ouput Content Buffering
55,223
function cache_callback ( $ output ) { if ( $ hd = @ fopen ( $ this -> cache_filename , 'w' ) ) { fputs ( $ hd , $ output ) ; fclose ( $ hd ) ; } return $ output ; }
Output Buffer Callback Function
55,224
public function getOffsetPosting ( ) { $ this -> getJournal ( ) -> assertIsSimpleJournal ( ) ; foreach ( $ this -> getJournal ( ) -> getPostings ( ) as $ posting ) { if ( $ posting != $ this ) { return $ posting ; } } }
Get offset posting
55,225
public function reverseTransform ( $ stringPoint ) { if ( ! $ stringPoint ) { return null ; } if ( null === $ stringPoint ) { throw new TransformationFailedException ( sprintf ( 'An area with number "%s" does not exist!' , $ stringPoint ) ) ; } if ( is_array ( $ stringPoint ) ) { $ stringPoint = $ stringPoint [ 'gpsCoo...
Transforms a string to an object .
55,226
public function findVendorForSlug ( $ slug ) { $ criteria = Criteria :: create ( ) -> where ( Criteria :: expr ( ) -> eq ( 'slug' , $ slug ) ) ; return $ this -> getVendors ( ) -> matching ( $ criteria ) -> first ( ) ; }
Find Vendor given slug
55,227
public static function decodeUnicodeString ( $ chrs ) { $ chrs = ( string ) $ chrs ; $ utf8 = '' ; $ strlenChrs = strlen ( $ chrs ) ; for ( $ i = 0 ; $ i < $ strlenChrs ; $ i ++ ) { $ ordChrsC = ord ( $ chrs [ $ i ] ) ; switch ( true ) { case preg_match ( '/\\\u[0-9A-F]{4}/i' , substr ( $ chrs , $ i , 6 ) ) : $ utf16 =...
Decode Unicode Characters from \ u0000 ASCII syntax .
55,228
protected function _decodeValue ( ) { switch ( $ this -> token ) { case self :: DATUM : $ result = $ this -> tokenValue ; $ this -> _getNextToken ( ) ; return ( $ result ) ; case self :: LBRACE : return ( $ this -> _decodeObject ( ) ) ; case self :: LBRACKET : return ( $ this -> _decodeArray ( ) ) ; } }
Recursive driving routine for supported toplevel tops
55,229
protected function _eatWhitespace ( ) { if ( preg_match ( '/([\t\b\f\n\r ])*/s' , $ this -> source , $ matches , PREG_OFFSET_CAPTURE , $ this -> offset ) && $ matches [ 0 ] [ 1 ] == $ this -> offset ) { $ this -> offset += strlen ( $ matches [ 0 ] [ 0 ] ) ; } }
Removes whitespace characters from the source input
55,230
protected static function _utf162utf8 ( $ utf16 ) { if ( function_exists ( 'mb_convert_encoding' ) ) { return mb_convert_encoding ( $ utf16 , 'UTF-8' , 'UTF-16' ) ; } $ bytes = ( ord ( $ utf16 { 0 } ) << 8 ) | ord ( $ utf16 { 1 } ) ; switch ( true ) { case ( ( 0x7F & $ bytes ) == $ bytes ) : return chr ( 0x7F & $ bytes...
Convert a string from one UTF - 16 char to one UTF - 8 char .
55,231
final public function reportError ( $ errno , $ errstr , $ errfile , $ errline , array $ errcontext = array ( ) ) { $ this -> _addRow ( array ( $ errstr ) , $ this -> _formatLocation ( $ errfile , $ errline ) , self :: ERROR ) ; }
logs a PHP error to the console as an error
55,232
final public function reportException ( \ Exception $ e ) { $ this -> _addRow ( array ( $ e -> getMessage ( ) ) , $ this -> _formatLocation ( $ e -> getFile ( ) , $ e -> getLine ( ) ) , self :: WARN ) ; }
logs a PHP exception to the console as a warn
55,233
public static function phone ( $ value , $ format ) { $ value = preg_replace ( '/[^0-9]+/' , '' , $ value ) ; if ( is_array ( $ format ) ) { $ length = mb_strlen ( $ value ) ; if ( $ length >= 11 ) { $ format = $ format [ 11 ] ; } else if ( $ length >= 10 ) { $ format = $ format [ 10 ] ; } else { $ format = $ format [ ...
Format a phone number . A phone number can support multiple variations depending on how many numbers are present .
55,234
protected static function _replaceRuleText ( $ text , $ rule ) { for ( $ parts = 1 ; $ parts < 20 ; $ parts ++ ) { if ( false === strpos ( $ rule , "{T$parts}" ) ) break ; } if ( 1 === $ parts ) { return str_replace ( [ "T" , "T1" ] , $ text , $ rule ) ; } $ text = str_replace ( "\\|" , "<<__E\$C@P#D__>>" , $ text ) ; ...
Replaced found text for a rule .
55,235
public function getRelationship ( $ key ) { if ( isset ( $ this -> relationships [ $ key ] ) ) { return $ this -> relationships [ $ key ] ; } return null ; }
Gets a relationship from this entity . Returns null if the relationship doesn t exist .
55,236
public function pushData ( Entity $ entity ) { if ( $ this -> isMany ( ) ) { $ this -> primaryData [ ] = $ entity ; return $ this ; } $ this -> primaryData = $ entity ; return $ this ; }
Pushes entities to this resource .
55,237
protected function hex2rgb ( $ hexcolor ) { preg_match ( "/^#{0,1}([0-9a-f]{1,6})$/i" , $ hexcolor , $ match ) ; if ( ! isset ( $ match [ 1 ] ) ) { return [ ] ; } $ color = $ match [ 1 ] ; if ( 6 == strlen ( $ color ) ) { list ( $ r , $ g , $ b ) = [ $ color [ 0 ] . $ color [ 1 ] , $ color [ 2 ] . $ color [ 3 ] , $ col...
Return RGB array from hex color .
55,238
public function get_html_path ( $ resource_path ) { $ uri = $ this -> sm -> get ( 'pegase.core.request' ) -> get_uri ( ) ; $ uri = explode ( '?' , $ uri ) ; $ uri = $ uri [ 0 ] ; $ nb = substr_count ( $ uri , '/' ) - 1 ; $ path = "" ; for ( $ i = 0 ; $ i < $ nb ; $ i ++ ) { $ path .= "../" ; } $ pos = strpos ( $ resour...
relatif pour les liens dans le html
55,239
protected function _stringableSplit ( $ subject , $ separator ) { $ subject = $ this -> _normalizeString ( $ subject ) ; $ separator = $ this -> _normalizeString ( $ separator ) ; return explode ( $ separator , $ subject ) ; }
Splits a stringable into pieces using a separator .
55,240
public static function get_mime_type ( $ filename ) { if ( extension_loaded ( 'fileinfo' ) ) { try { $ finfo = new \ finfo ( FILEINFO_MIME_TYPE ) ; return $ finfo -> file ( $ filename ) ; } catch ( \ Exception $ e ) { } } if ( function_exists ( 'mime_content_type' ) ) { try { return mime_content_type ( $ filename ) ; }...
Determine the mime - type of a file .
55,241
public static function normalize_filename ( $ input ) { if ( empty ( $ input ) ) { return false ; } $ pathinfo = pathinfo ( $ input ) ; $ ext = mb_strtolower ( $ pathinfo [ 'extension' ] ) ; if ( $ ext === 'jpeg' ) { $ ext = 'jpg' ; } $ filename = $ pathinfo [ 'filename' ] . '.' . $ ext ; $ filename = static :: sanitiz...
This helps us create normalized filenames .
55,242
public static function sanitize_filename ( $ i , $ allow_subdirs = false , $ allowabsolute = false ) { $ i = trim ( $ i ) ; $ replacements = [ '../' , './' ] ; if ( $ allow_subdirs === false ) { $ replacements [ ] = '/' ; } if ( $ allowabsolute !== true && $ i { 0 } === '/' ) { $ i = substr ( $ i , 1 ) ; } return str_r...
Sanitize a filename .
55,243
public static function create_directory_structure ( $ folders , $ base_dir ) { if ( ! empty ( $ folders ) && is_array ( $ folders ) ) { foreach ( $ folders as $ name => $ subfolders ) { if ( ! file_exists ( $ base_dir . $ name . '/' ) ) { mkdir ( $ base_dir . $ name . '/' ) ; } touch ( $ base_dir . $ name . '/index.htm...
Create a complete directory structure in a given path .
55,244
public static function rrmdir ( $ path ) { if ( is_file ( $ path ) ) { return unlink ( $ path ) ; } elseif ( is_dir ( $ path ) ) { $ dir_members = scandir ( $ path ) ; foreach ( $ dir_members as $ member ) { if ( $ member !== '.' && $ member !== '..' ) { static :: rrmdir ( $ path . '/' . $ member ) ; } } return @ rmdir...
Delete a folder and all subfolders .
55,245
public static function unzip ( $ file , $ destination ) { if ( ! file_exists ( $ file ) ) { return false ; } if ( ! file_exists ( $ destination ) ) { mkdir ( $ destination ) ; } if ( class_exists ( 'ZipArchive' ) ) { $ result = static :: unzip_using_ziparchive ( $ file , $ destination ) ; if ( $ result === true ) { ret...
Unzip a zip file into a directory .
55,246
public static function unzip_using_ziparchive ( $ file , $ destination ) { $ za = new \ ZipArchive ; $ zares = $ za -> open ( $ file ) ; if ( $ zares === true ) { $ za -> extractTo ( $ destination ) ; $ za -> close ( ) ; return true ; } else { return false ; } }
Unzip a file into a directory using the ZipArchive class .
55,247
public static function get_file_type_from_mime ( $ mime ) { $ validtypes = [ 'application' , 'audio' , 'image' , 'message' , 'multipart' , 'text' , 'video' ] ; if ( mb_stripos ( $ mime , '/' ) === false ) { return false ; } $ iparts = explode ( '/' , $ mime ) ; if ( count ( $ iparts ) !== 2 ) { return false ; } return ...
Get the general file type from a mime type .
55,248
public static function make_human_readable_filesize ( $ bytes ) { $ units = array ( 'B' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' ) ; $ num_units = count ( $ units ) ; $ size = $ bytes ; foreach ( $ units as $ i => $ unit ) { if ( $ size < 1024 || ( ( $ i + 1 ) === $ num_units ) ) { return round ( $ size , 2 ) . $ unit ; } $ ...
Convert bytes into a human - readable format .
55,249
public static function dirsize ( $ dir , $ createifmissing = false ) { $ dirsize = 0 ; if ( ! file_exists ( $ dir ) ) { if ( $ createifmissing === true ) { mkdir ( $ dir ) ; return 0 ; } throw new \ Exception ( 'Directory does not exist!' , 400 ) ; } $ dir_info = scandir ( $ dir ) ; if ( $ dir { ( mb_strlen ( $ dir ) -...
Get the disk usage of a given directory .
55,250
static function guessMimeType ( $ file , $ def = 'application/octet-stream' ) { $ ext = substr ( strrchr ( strtolower ( $ file ) , '.' ) , 1 ) ; switch ( $ ext ) { case 'gif' : case 'jpeg' : case 'png' : return "image/$ext" ; case 'jpg' : return 'image/jpeg' ; case 'mp4' : case 'mpeg' : case 'avi' : return "video/$ext"...
Guess Mime type from file name
55,251
public static function getConstants ( $ name ) { if ( isset ( self :: $ _const [ $ name ] ) ) { return self :: $ _const [ $ name ] ; } $ self = new \ ReflectionClass ( new static ( ) ) ; $ contants = $ self -> getConstants ( ) ; $ prefix = strtoupper ( $ name ) . '_' ; $ prefixLength = strlen ( $ prefix ) ; $ prefixOff...
get constants by name
55,252
public function fillerAction ( $ plugin , Request $ request ) { $ response = $ this -> getCacheTimeKeeper ( ) -> getResponse ( ) ; if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } $ chain = $ this -> get ( 'anime_db.plugin.filler' ) ; if ( ! ( $ filler = $ chain -> getPlugin ( $ plugin ) ) ) { t...
Create new item from source fill .
55,253
public function searchFillerAction ( Request $ request ) { $ chain = $ this -> get ( 'anime_db.plugin.filler' ) ; $ response = $ this -> getResponseFromChain ( $ chain ) ; if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } $ entity = new SearchFiller ( $ chain ) ; $ form = $ this -> createForm ( n...
Search filler by URL for fill item .
55,254
protected function getResponseFromChain ( Chain $ chain ) { if ( ! $ chain -> getPlugins ( ) ) { throw $ this -> createNotFoundException ( 'No any plugins' ) ; } $ names = '' ; foreach ( $ chain -> getPlugins ( ) as $ plugin ) { $ names .= '|' . $ plugin -> getName ( ) ; } return $ this -> getCacheTimeKeeper ( ) -> get...
Get response from plugins chain .
55,255
private function serialize ( EntityMetadata $ metadata ) { switch ( $ this -> serializer ) { case self :: SERIALIZER_PHP : return serialize ( $ metadata ) ; case self :: SERIALIZER_IGBINARY : return igbinary_serialize ( $ metadata ) ; default : throw new RuntimeException ( 'Unable to handle serialization of the metadat...
Serializes the metadata object based on the selected serializer .
55,256
private function unserialize ( $ value ) { switch ( $ this -> serializer ) { case self :: SERIALIZER_PHP : return unserialize ( $ value ) ; case self :: SERIALIZER_IGBINARY : return igbinary_unserialize ( $ value ) ; default : throw new RuntimeException ( 'Unable to handle unserialization of the metadata object' ) ; } ...
Unserializes the metadata object based on the selected serializer .
55,257
private function setPercentSize ( \ Jb \ Bundle \ TagCloudBundle \ Model \ Tag $ tag , $ max ) { $ percent = ( $ tag -> getCounter ( ) / $ max ) * 100 ; $ weight = floor ( $ percent / 10 ) ; if ( $ percent >= 5 ) { $ weight ++ ; } if ( $ percent >= 80 && $ percent < 100 ) { $ weight = 8 ; } elseif ( $ percent == 100 ) ...
Set a size
55,258
public function documentNotFound ( $ proxy , Identifier $ identifier ) { $ eventArgs = new DocumentNotFoundEventArgs ( $ proxy , $ this -> dm , $ identifier ) ; $ this -> evm -> dispatchEvent ( Event :: documentNotFound , $ eventArgs ) ; return $ eventArgs -> isExceptionDisabled ( ) ; }
Return whether the exceptionDisabled flag was set .
55,259
protected function installEntryFiles ( PackageInterface $ package ) { foreach ( $ this -> getEntryFileLocations ( $ package ) as $ src => $ dest ) { $ copied = $ this -> filesystem -> copyFile ( $ src , $ dest ) ; $ this -> io -> notice ( sprintf ( ' <fg=default>Copying <fg=magenta>%1$s</> to <fg=magenta>%2$s</> -</...
Install each must - use plugin entry file
55,260
protected function uninstallEntryFiles ( PackageInterface $ package ) { foreach ( $ this -> getEntryFileLocations ( $ package ) as $ dest ) { $ unlinked = $ this -> filesystem -> unlinkFile ( $ dest ) ; $ this -> io -> notice ( sprintf ( ' <fg=default>Removing <fg=magenta>%1$s</> -</> %2$s' , $ dest , $ unlinked ? '...
Uninstall each must - use plugin entry file
55,261
protected function getPackageExtra ( PackageInterface $ package , $ key , $ default = null ) { $ extra = $ package -> getExtra ( ) ; return array_key_exists ( $ key , $ extra ) ? $ extra [ $ key ] : $ default ; }
Get an item from the package extra array
55,262
protected function getPackageEntryPoints ( PackageInterface $ package ) { $ dir = $ this -> composer -> getInstallationManager ( ) -> getInstallPath ( $ package ) ; $ entry = $ this -> getPackageExtra ( $ package , 'wordpress-muplugin-entry' ) ; $ entryPoints = $ entry ? ( is_array ( $ entry ) ? $ entry : [ $ entry ] )...
Get the package entry points
55,263
protected function looksLikePlugin ( $ file ) { if ( ! $ file || ! $ this -> filesystem -> isFile ( $ file ) || ! $ this -> filesystem -> isReadable ( $ file ) ) { return false ; } $ chunk = str_replace ( "\r" , "\n" , file_get_contents ( $ file , false , null , 0 , 8192 ) ) ; return preg_match ( '/^[ \t\/*#@]*Plugin N...
Does the file look like a WordPress plugin?
55,264
public function RenderBlock ( $ block ) { $ templateFile = $ this -> BuiltInTemplateFile ( ) ; $ blockFile = Path :: AddExtension ( $ templateFile , $ block , true ) ; $ blockFileExt = Path :: AddExtension ( $ blockFile , 'phtml' ) ; if ( ! File :: Exists ( $ blockFileExt ) ) { return '' ; } ob_start ( ) ; require $ bl...
Renders a block by name
55,265
public function setFromArray ( array $ fields ) { foreach ( $ fields as $ key => $ value ) { $ this -> fields [ $ key ] = $ value ; unset ( $ key ) ; unset ( $ value ) ; } }
Sets the fields on the object .
55,266
public function createAddCommentForm ( Content $ content , $ user = null ) { $ comment = new Comment ( ) ; $ comment -> setContent ( $ content ) ; if ( $ user !== 'anon.' ) { $ comment -> setEmail ( $ user -> getEmail ( ) ) ; } $ form = $ this -> form_factory -> create ( new CommentType ( ) , $ comment ) ; return $ for...
Creates a form to comment on a content .
55,267
public function attachParents ( array $ parents ) { $ this -> _parents = [ ] ; foreach ( $ parents as $ parent ) { $ this -> attachParent ( $ parent , false ) ; } }
Loops on each given parent and attach it to this object .
55,268
public function hasParent ( $ parentClassName ) { $ found = false ; $ this -> alongParents ( function ( $ parent ) use ( $ parentClassName , & $ found ) { if ( $ parent instanceof $ parentClassName ) { $ found = true ; return false ; } return true ; } ) ; return $ found ; }
Returns true if the class has a given parent .
55,269
public function withFirstParent ( $ parentClassName , callable $ callback , callable $ notFoundCallback = null ) { $ result = null ; if ( $ this -> hasParent ( $ parentClassName ) ) { $ parent = $ this -> getFirstParent ( $ parentClassName ) ; $ result = call_user_func ( $ callback , $ parent ) ; } elseif ( null !== $ ...
Will fetch the first parent which matches the given class name .
55,270
public function getFirstParent ( $ parentClassName ) { $ foundParent = null ; $ this -> alongParents ( function ( $ parent ) use ( $ parentClassName , & $ foundParent ) { if ( $ parent instanceof $ parentClassName ) { $ foundParent = $ parent ; return false ; } return true ; } ) ; if ( null === $ foundParent ) { throw ...
Returns the first found instance of the desired parent .
55,271
public function setView ( $ viewName ) { $ view = $ this -> pathToView . DIRECTORY_SEPARATOR . strtolower ( $ viewName ) . '.php' ; if ( ! file_exists ( $ view ) ) { throw new Exception \ LookupException ( 'View: "' . $ view . '" could not be found.' ) ; } $ this -> viewQueue [ $ viewName ] = $ view ; }
formats and prepares view for inclusion
55,272
public function fetchCSS ( ) { $ string = "" ; if ( empty ( $ this -> queuedCSS ) ) { return $ string ; } foreach ( $ this -> queuedCSS as $ sheet ) { $ string .= '<link rel="stylesheet" href="' . $ sheet . '">' . "\r\n" ; } return $ string ; }
Helper method for grabbing aggregated css files
55,273
public function fetchJS ( ) { $ string = "<script>baseURL = '" . $ this -> router -> baseURL ( ) . "/'</script>\r\n" ; if ( empty ( $ this -> queuedJS ) ) { return $ string ; } foreach ( $ this -> queuedJS as $ script ) { $ string .= '<script src="' . $ script . '"></script>' . "\r\n" ; } return $ string ; }
Helper method for grabbing aggregated JS files
55,274
public function isExists ( ) { clearstatcache ( true , ( string ) $ this -> resource ) ; return is_file ( ( string ) $ this -> resource ) ; }
Returns true if the resource exists in the filesystem .
55,275
public function saveAction ( Request $ request ) { $ json_nodes = $ request -> get ( 'nodes' ) ; if ( $ json_nodes ) { $ this -> em = $ this -> getDoctrine ( ) -> getManager ( ) ; foreach ( $ json_nodes as $ id => $ obj ) { $ contentNode = $ this -> em -> find ( ContentNode :: class , $ id ) ; if ( $ contentNode ) { $ ...
AJAX save endpoint not related to the CRUD
55,276
public function simpleUpdateAction ( Request $ request , ContentNode $ contentNode ) { return $ this -> updateAction ( $ request , $ contentNode , true ) ; }
validates the simple ContentNode Form
55,277
public function updateAction ( Request $ request , ContentNode $ contentNode , $ isSimpleForm = false ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ repository = $ this -> getDoctrine ( ) -> getRepository ( 'MMCmfNodeBundle:Node' ) ; $ rootNode = null ; if ( ( int ) $ request -> get ( 'root_node' ) ) { $ ro...
validates the general ContentNode Form
55,278
public function createSimpleEditForm ( ContentNode $ contentNode , Node $ rootNode = null ) { $ contentNodeClassName = get_class ( $ contentNode ) ; $ contentNodeParser = $ this -> get ( 'mm_cmf_content.content_parser' ) ; $ simpleFormData = $ contentNodeParser -> getSimpleForm ( $ contentNodeClassName ) ; if ( isset (...
Returns the configured Simple Form for Frontend Editing purpose
55,279
public function createFromId ( AbstractPageRouteConfiguration $ routeConfiguration , $ pageId ) { $ page = $ this -> repository -> find ( $ pageId ) ; return $ this -> create ( $ routeConfiguration , $ page ) ; }
Create a new route instance from a page id
55,280
protected function buildUrlFromPath ( array $ path ) { array_shift ( $ path ) ; if ( count ( $ path ) === 0 && $ this -> treeStrategy -> isHomeTreeRoot ( ) ) { return '/' ; } return array_reduce ( $ path , function ( $ carry , NestedSetRoutingPageInterface $ item ) { $ carry .= '/' . $ item -> getSlug ( ) ; return $ ca...
Build an url from a path
55,281
public function process ( array $ input ) { if ( $ this -> v -> validate ( $ input ) ) { Event :: fire ( "form.processing" , array ( $ input ) ) ; return $ this -> callRepository ( $ input ) ; } else { $ this -> errors = $ this -> v -> getErrors ( ) ; throw new ValidationException ; } }
Process the input and calls the repository
55,282
protected function isUpdate ( $ input ) { return ( isset ( $ input [ $ this -> id_field_name ] ) && ! empty ( $ input [ $ this -> id_field_name ] ) ) ; }
Check if the operation is update or create
55,283
public function delete ( array $ input ) { if ( isset ( $ input [ $ this -> id_field_name ] ) && ! empty ( $ input [ $ this -> id_field_name ] ) ) { try { $ this -> r -> delete ( $ input [ $ this -> id_field_name ] ) ; } catch ( ModelNotFoundException $ e ) { $ this -> errors = new MessageBag ( array ( "model" => "Elem...
Run delete on the repository
55,284
public function getQNVarName ( ) { return \ lyquidity \ xml \ qname ( $ this -> _varName -> ToString ( ) , $ this -> getContext ( ) -> NamespaceManager -> getNamespaces ( ) , true ) ; }
Get the VarName as a QName
55,285
public function setCallback ( $ callback = NULL ) { if ( NULL !== $ callback ) { $ pattern = '/^[$_\p{L}][$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]*+$/u' ; foreach ( explode ( '.' , $ callback ) as $ part ) { if ( ! preg_match ( $ pattern , $ part ) ) { throw new \ InvalidArgumentException ( sprintf ( "The callb...
set the JSONP callback pass NULL for not using a callback
55,286
public function setEncodingOptions ( $ encodingOptions ) { $ this -> encodingOptions = ( int ) $ encodingOptions ; return $ this -> setPayload ( json_decode ( $ this -> data ) ) ; }
set options used while encoding data to JSON re - encodes payload with new encoding setting
55,287
protected function update ( ) { if ( ! is_null ( $ this -> callback ) ) { $ this -> headers -> set ( 'Content-Type' , 'text/javascript' ) ; return $ this -> setContent ( sprintf ( '/**/%s(%s);' , $ this -> callback , $ this -> data ) ) ; } if ( ! $ this -> headers -> has ( 'Content-Type' ) || $ this -> headers -> get (...
update content and headers according to the JSON data and a set callback
55,288
public function getPluginsThatCanFillItem ( Item $ item , $ field ) { $ plugins = [ ] ; foreach ( $ this -> plugins as $ plugin ) { if ( $ plugin -> isCanRefill ( $ item , $ field ) || $ plugin -> isCanSearch ( $ item , $ field ) ) { $ plugins [ ] = $ plugin ; } } return $ plugins ; }
Get list of plugins that can fill item .
55,289
public function add_listener ( $ event_name , $ listener , $ priority = self :: PRIORITY , $ accepted_args = self :: ACCEPTED ) { if ( ! is_callable ( $ listener , true ) ) { throw new InvalidListenerException ( '$listener must be callable.' ) ; } if ( ! is_int ( $ priority ) ) { throw new \ InvalidArgumentException ( ...
Add an event listener that listens for a given event .
55,290
public function remove_listener ( $ event_name , $ listener , $ priority = self :: PRIORITY ) { if ( ! is_callable ( $ listener , true ) ) { throw new InvalidListenerException ( '$listener must be callable.' ) ; } if ( ! is_int ( $ priority ) ) { throw new \ InvalidArgumentException ( '$priority must be an int.' ) ; } ...
Remove an event listener for a given event .
55,291
public function add_subscriber ( EventSubscriber $ subscriber ) { foreach ( $ subscriber -> get_subscribed_events ( ) as $ event => $ params ) { if ( is_string ( $ params ) ) { $ this -> add_listener ( $ event , array ( $ subscriber , $ params ) ) ; } elseif ( is_array ( $ params ) && isset ( $ params [ 0 ] ) ) { $ met...
Add an event subscriber .
55,292
public function remove_subscriber ( EventSubscriber $ subscriber ) { foreach ( $ subscriber -> get_subscribed_events ( ) as $ event => $ params ) { if ( is_string ( $ params ) ) { $ this -> add_listener ( $ event , $ params ) ; } elseif ( is_array ( $ params ) && isset ( $ params [ 0 ] ) ) { $ method = $ params [ 0 ] ;...
Remove an event subscriber .
55,293
public function get_listener_priority ( $ event_name , $ listener ) { if ( ! is_callable ( $ listener , true ) ) { throw new InvalidListenerException ( '$listener must be callable.' ) ; } $ priority = has_filter ( $ event_name , $ listener ) ; if ( false === $ priority ) { return null ; } return $ priority ; }
Get the listener priority for a given event .
55,294
protected function loadConfigFile ( string $ key ) { $ key = strtolower ( $ key ) ; $ filename = $ this -> path . DIRECTORY_SEPARATOR . ucfirst ( $ key ) . Config :: CONFIG_FILE_EXTENSION ; if ( file_exists ( $ filename ) ) { $ this -> configuration [ $ key ] = require $ filename ; return ; } throw new ConfigException ...
Loads a configuration file in to memory
55,295
public function get ( string $ key ) { $ key = strtolower ( $ key ) ; if ( empty ( $ this -> configuration [ $ key ] ) ) { $ this -> loadConfigFile ( $ key ) ; } return $ this -> configuration [ $ key ] ; }
Get Configuration Item
55,296
public function addDashboardIcon ( $ dashboardRoleId , $ appTemplateId ) { $ url = sprintf ( '%s://%s%s/api/v1/dashboard/%s/application' , $ this -> scheme , $ this -> domain , $ this -> sufix , $ dashboardRoleId ) ; if ( $ this -> logger ) { $ this -> logger -> info ( 'Appsco.AppscoClient.addDashboardIcon' , array ( '...
Creates a dashboard icon
55,297
public function evaluateArgs ( array $ args ) : void { array_shift ( $ args ) ; if ( count ( $ args ) < 2 ) { $ this -> out -> red ( "Not enough arguments: expects 2, got " . ( count ( $ args ) - 1 ) . "." ) ; return ; } $ this -> setName ( $ args [ 0 ] ) ; $ this -> setLocation ( $ args [ 1 ] ) ; if ( isset ( $ args [...
Take in an array of args and evalutate them
55,298
public function additionalArgs ( array $ args ) : void { foreach ( $ args as $ a ) { if ( substr ( $ a , 0 , strlen ( "--extends=" ) ) == "--extends=" ) { $ this -> extends = explode ( "=" , $ a ) ; $ this -> extends = $ this -> extends [ 1 ] ; continue ; } if ( $ a == "--no-factory" ) { $ this -> createFactory = false...
Evaluate optional additional args
55,299
protected function getStateFormatted ( Document $ document ) { switch ( $ document -> getState ( ) ) { case Document :: DOCUMENT_STATE_ACTIVE : $ this -> stateClass = 'success' ; return 'Attivo' ; break ; case Document :: DOCUMENT_STATE_DEACTIVE : $ this -> stateClass = 'warning' ; return 'Disattivo' ; break ; case Doc...
This will fill the stateClass as well