idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
9,000
|
public function getCMSFields ( ) { $ fields = parent :: getCMSFields ( ) ; $ field = SortableUploadField :: create ( 'Images' , _t ( 'CarouselPage.db_Images' ) ) ; $ field -> setFolderName ( $ this -> getClassFolder ( ) ) ; $ field -> setFileEditFields ( 'getCarouselEditFields' ) ; $ root = $ fields -> fieldByName ( 'Root' ) ; $ tab = $ root -> fieldByName ( 'Images' ) ; if ( ! $ tab ) { $ tab = Tab :: create ( 'Images' ) ; $ tab -> setTitle ( _t ( 'CarouselPage.db_Images' ) ) ; $ root -> insertAfter ( $ tab , 'Main' ) ; } $ tab -> push ( $ field ) ; return $ fields ; }
|
Add the Images tab to the content form of the page .
|
9,001
|
public function getSettingsFields ( ) { $ fields = parent :: getSettingsFields ( ) ; $ settings = FieldGroup :: create ( FieldGroup :: create ( NumericField :: create ( 'Width' , _t ( 'CarouselPage.db_Width' ) ) , NumericField :: create ( 'Height' , _t ( 'CarouselPage.db_Height' ) ) , CheckboxField :: create ( 'Captions' , _t ( 'CarouselPage.db_Captions' ) ) ) ) ; $ settings -> setName ( 'Carousel' ) ; $ settings -> setTitle ( _t ( 'CarouselPage.SINGULARNAME' ) ) ; $ fields -> addFieldToTab ( 'Root.Settings' , $ settings ) ; return $ fields ; }
|
Add carousel related fields to the page settings .
|
9,002
|
public function parse ( ) { $ css = new Parser ( file_get_contents ( $ this -> path ) ) ; $ this -> leanCSS = $ css -> parse ( ) ; $ this -> blubberCSS = clone $ this -> leanCSS ; }
|
Begins parsing the CSS file
|
9,003
|
public function saveBlubber ( ) { $ fh = fopen ( $ this -> getDirname ( ) . '/' . $ this -> getBlubberName ( ) , 'w' ) ; fwrite ( $ fh , $ this -> blubberCSS -> render ( ) ) ; }
|
Saves the blubber CSS to the filesystem
|
9,004
|
public function saveLean ( ) { $ fh = fopen ( $ this -> getDirname ( ) . '/' . $ this -> getLeanName ( ) , 'w' ) ; fwrite ( $ fh , $ this -> leanCSS -> render ( ) ) ; }
|
Saves the lean CSS to the filesystem
|
9,005
|
protected function getBaseData ( ) { $ data = array ( ) ; $ data [ 'xKey' ] = $ this -> getCardknoxKey ( ) ; $ data [ 'xVersion' ] = '4.5.4' ; $ data [ 'xSoftwareName' ] = 'omnipay' ; $ data [ 'xSoftwareVersion' ] = '1' ; $ data [ 'xCommand' ] = $ this -> action ; return $ data ; }
|
Base data used only for the API .
|
9,006
|
protected function build ( ) { $ sql = $ this -> start . "\n" . ( $ this -> from ? $ this -> from . "\n" : null ) . ( $ this -> join ? $ this -> join : null ) . ( $ this -> set ? $ this -> set . "\n" : null ) . ( $ this -> where ? $ this -> where . "\n" : null ) . ( $ this -> groupby ? $ this -> groupby . "\n" : null ) . ( $ this -> orderby ? $ this -> orderby . "\n" : null ) . ( $ this -> limit ? $ this -> limit . "\n" : null ) . ( $ this -> offset ? $ this -> offset . "\n" : null ) . ";" ; return $ sql ; }
|
Build the SQL query from its parts .
|
9,007
|
public function rightJoin ( $ table , $ condition ) { if ( $ this -> dialect == 'sqlite' ) { throw new BuildException ( "SQLite does not support RIGHT JOIN" ) ; } return $ this -> createJoin ( $ table , $ condition , 'RIGHT OUTER' ) ; }
|
Build the right join part .
|
9,008
|
function paginateCount ( $ conditions , $ recursive ) { $ sql = $ this -> sql ; return count ( $ this -> query ( $ sql ) ) ; }
|
Esta funcion sobreescribe a la del paginador . Como son consultas guardadas en la tabla query tengo que calcular la cantidad de registros para que pagine bien .
|
9,009
|
function paginate ( $ conditions , $ fields , $ order , $ limit , $ page , $ recursive ) { $ sql = $ this -> sql ; $ sql .= " LIMIT " . $ this -> limit . " " ; $ sql .= " OFFSET " . ( ( $ page - 1 ) * $ this -> limit ) ; return $ this -> query ( $ sql ) ; }
|
Esta funcion sobreescribe a la del paginador . Como son consultas guardadas en la tabla query tengo que reescribir el limit y el offset para poder mostrar por pantalla
|
9,010
|
protected function respondWithItem ( $ item , $ resource_name = '' , array $ links = [ ] , array $ included = [ ] ) { $ resource = new Item ( $ item , $ resource_name , $ links , $ included ) ; return $ this -> respondWithArray ( $ resource -> toArray ( ) ) ; }
|
Response with item
|
9,011
|
public function transform ( $ value ) { if ( $ value === null || $ value == '' ) { return null ; } if ( ! ( $ value instanceof Page ) ) { throw new TransformationFailedException ( 'Expected an instance of a concrete5 page object.' ) ; } return intval ( $ value -> getCollectionID ( ) ) ; }
|
Converts a concrete5 page object to an integer .
|
9,012
|
public function getParameters ( array $ config ) { $ params = [ 'opifer_eav.attribute_class' => $ config [ 'attribute_class' ] , 'opifer_eav.media_class' => $ config [ 'media_class' ] , 'opifer_eav.nestable_class' => $ config [ 'nestable_class' ] , 'opifer_eav.option_class' => $ config [ 'option_class' ] , 'opifer_eav.schema_class' => $ config [ 'schema_class' ] , 'opifer_eav.valueset_class' => $ config [ 'valueset_class' ] , ] ; foreach ( $ config [ 'entities' ] as $ label => $ entity ) { $ params [ 'opifer_eav.entities' ] [ $ label ] = $ entity ; } return $ params ; }
|
Simplifying parameter syntax
|
9,013
|
public function prepend ( ContainerBuilder $ container ) { $ configs = $ container -> getExtensionConfig ( $ this -> getAlias ( ) ) ; $ config = $ this -> processConfiguration ( new Configuration ( ) , $ configs ) ; $ parameters = $ this -> getParameters ( $ config ) ; foreach ( $ parameters as $ key => $ value ) { $ container -> setParameter ( $ key , $ value ) ; } $ resolvableEntities = [ 'Opifer\EavBundle\Model\AttributeInterface' => $ config [ 'attribute_class' ] , 'Opifer\EavBundle\Model\OptionInterface' => $ config [ 'option_class' ] , 'Opifer\EavBundle\Model\SchemaInterface' => $ config [ 'schema_class' ] , 'Opifer\EavBundle\Model\ValueSetInterface' => $ config [ 'valueset_class' ] , ] ; if ( $ config [ 'nestable_class' ] != '' ) { $ resolvableEntities [ 'Opifer\EavBundle\Model\Nestable' ] = $ config [ 'nestable_class' ] ; } if ( $ config [ 'media_class' ] != '' ) { $ resolvableEntities [ 'Opifer\EavBundle\Model\MediaInterface' ] = $ config [ 'media_class' ] ; } foreach ( $ container -> getExtensions ( ) as $ name => $ extension ) { switch ( $ name ) { case 'doctrine' : $ container -> prependExtensionConfig ( $ name , [ 'orm' => [ 'resolve_target_entities' => $ resolvableEntities , ] , ] ) ; break ; } } }
|
Prepend our config before other bundles so we can preset their config with our parameters
|
9,014
|
public static function encode ( $ data , $ prettyPrint = false ) { if ( $ prettyPrint ) { if ( version_compare ( PHP_VERSION , '5.4.0' , '>=' ) && defined ( 'JSON_PRETTY_PRINT' ) ) { return json_encode ( $ data , JSON_PRETTY_PRINT ) ; } else { $ jsonPretty = new JsonPretty ( ) ; return $ jsonPretty -> prettify ( $ data , null , ' ' ) ; } } return json_encode ( $ data ) ; }
|
Encodes an array to json strutcture
|
9,015
|
protected function provideTemplatingSystem ( Application $ app ) { $ templateDir = __DIR__ . '/../../../data/templates' ; $ composerTemplatePath = __DIR__ . '/../../../../templates' ; if ( file_exists ( $ composerTemplatePath ) ) { $ templateDir = $ composerTemplatePath ; } $ app [ 'transformer.template.location' ] = $ templateDir ; $ app [ 'transformer.template.path_resolver' ] = $ app -> share ( function ( $ container ) { return new PathResolver ( $ container [ 'transformer.template.location' ] ) ; } ) ; $ app [ 'transformer.template.factory' ] = $ app -> share ( function ( $ container ) { return new Factory ( $ container [ 'transformer.template.path_resolver' ] , $ container [ 'serializer' ] ) ; } ) ; $ app [ 'transformer.template.collection' ] = $ app -> share ( function ( $ container ) { return new Template \ Collection ( $ container [ 'transformer.template.factory' ] , $ container [ 'transformer.writer.collection' ] ) ; } ) ; }
|
Initializes the templating system in the container .
|
9,016
|
public function getIndentationPrefix ( $ times = 1 ) { if ( ! is_integer ( $ times ) ) { throw new \ InvalidArgumentException ( 'The times parameter has to be an integer' ) ; } $ indentation = '' ; for ( $ i = 0 ; $ i < $ times ; $ i ++ ) { $ indentation .= $ this -> getTemplate ( ) -> getIndentation ( ) ; } return $ indentation ; }
|
Returns all the indentation that should be put before the current line
|
9,017
|
public function convertLinesToCode ( array $ lines ) { if ( 0 === count ( $ lines ) ) { return '' ; } if ( 0 !== strlen ( $ this -> getTemplate ( ) -> getIndentationPrefix ( ) ) ) { foreach ( $ lines as $ lineNumber => $ line ) { if ( null === $ line ) { unset ( $ lines [ $ lineNumber ] ) ; } elseif ( '' === trim ( $ line ) ) { $ lines [ $ lineNumber ] = '' ; } } } return implode ( $ this -> getTemplate ( ) -> getEol ( ) , $ lines ) . $ this -> getTemplate ( ) -> getEol ( ) ; }
|
Converts an array of lines into code including the current indentation
|
9,018
|
public function getBlurbLines ( ) { $ lines = [ ] ; $ lines [ ] = '' ; $ lines [ ] = '/************************************************************************************************' ; $ lines [ ] = ' ** THIS IS AN AUTOMATICALLY GENERATED BASE FILE AND SHOULD NOT BE MANUALLY EDITED **' ; $ lines [ ] = ' ** All user content should be placed within <user-additions' . ' part="(name)"></user-additions' . '> **' ; $ lines [ ] = ' ************************************************************************************************/' ; $ lines [ ] = '' ; $ lines [ ] = '/*' ; $ lines [ ] = ' * This file was automatically generated with \'Autocode\'' ; $ lines [ ] = ' * by Jose Diaz-Angulo <jose@diazangulo.com>' ; $ lines [ ] = ' * ' ; $ lines [ ] = ' * For the full copyright and license information, please view the LICENSE' ; $ lines [ ] = ' * file that was distributed with the package\'s source code.' ; $ lines [ ] = ' */' ; $ lines [ ] = '' ; return $ lines ; }
|
Get the default Blurb
|
9,019
|
public function from_path ( string $ path , $ type = 'page' ) : ? string { $ parent = null ; if ( $ root = $ this -> opt -> from_code ( $ type , self :: $ option_root_id ) ) { $ parts = explode ( '/' , $ path ) ; $ parent = $ root ; foreach ( $ parts as $ i => $ p ) { $ is_not_last = $ i < ( \ count ( $ parts ) - 1 ) ; if ( ! empty ( $ p ) ) { $ prev_parent = $ parent ; $ parent = $ this -> opt -> from_code ( $ p . ( $ is_not_last ? '/' : '' ) , $ prev_parent ) ; if ( ! $ parent && $ is_not_last ) { $ parent = $ this -> opt -> from_code ( $ p , $ prev_parent ) ; } } } } return $ parent ? : null ; }
|
Returns the option s ID corresponds to the given path .
|
9,020
|
public function get_all ( string $ id_option = null , string $ type = 'page' ) : ? array { if ( $ id_option = $ this -> _get_id_option ( $ id_option , $ type ) ) { return $ this -> pref -> options ( $ id_option ? : $ this -> get_current ( ) ) ; } return null ; }
|
Returns the full list of permissions existing in the given option
|
9,021
|
public function get_full ( $ id_option = null , string $ type = 'page' ) : ? array { if ( $ id_option = $ this -> _get_id_option ( $ id_option , $ type ) ) { return $ this -> pref -> full_options ( $ id_option ? : $ this -> get_current ( ) ) ; } return null ; }
|
Returns the full list of permissions existing in the given option with all the current user s preferences
|
9,022
|
public function is ( string $ path , string $ type = 'page' ) : ? string { return $ this -> from_path ( $ path , $ type ) ; }
|
Checks if an option corresponds to the given path .
|
9,023
|
public function customize ( array $ arr ) : array { $ res = [ ] ; if ( isset ( $ arr [ 0 ] ) ) { foreach ( $ arr as $ a ) { if ( isset ( $ a [ 'id' ] ) && $ this -> has ( $ a [ 'id' ] ) ) { $ res [ ] = $ a ; } } } else if ( isset ( $ arr [ 'items' ] ) ) { $ res = $ arr ; unset ( $ res [ 'items' ] ) ; foreach ( $ arr [ 'items' ] as $ a ) { if ( isset ( $ a [ 'id' ] ) && $ this -> has ( $ a [ 'id' ] ) ) { if ( ! isset ( $ res [ 'items' ] ) ) { $ res [ 'items' ] = [ ] ; } $ res [ 'items' ] [ ] = $ a ; } } } return $ res ; }
|
Adapts a given array of options to user s permissions
|
9,024
|
public function add ( string $ id_option , string $ type = 'page' ) : ? int { if ( $ id_option = $ this -> _get_id_option ( $ id_option , $ type ) ) { return $ this -> pref -> set_by_option ( $ id_option , [ ] ) ; } return null ; }
|
Grants a new permission to a user or a group
|
9,025
|
public function remove ( $ id_option , string $ type = 'page' ) : ? int { if ( $ id_option = $ this -> _get_id_option ( $ id_option , $ type ) ) { return $ this -> pref -> delete ( $ id_option ) ; } return null ; }
|
Deletes a preference for a path or an ID .
|
9,026
|
public function read_option ( string $ id_option = null ) : ? bool { if ( bbn \ str :: is_uid ( $ id_option ) ) { $ root = self :: get_option_id ( 'options' ) ; $ id_to_check = $ this -> opt -> from_code ( 'opt' . $ id_option , $ root ) ; return $ this -> has ( $ id_to_check , 'options' ) ; } return null ; }
|
Checks if the category represented by the given option ID is readable by the current user
|
9,027
|
public function renderMustache ( $ filename , $ data ) { $ data [ 'getView' ] = function ( $ name , $ data ) { return $ this -> getView ( $ name , $ data ) ; } ; return parent :: renderMustache ( $ filename , $ data ) ; }
|
Attach getView function to the mustache view
|
9,028
|
public static function availableTypes ( ) { return [ self :: CONDITION_EQUAL , self :: CONDITION_NOT_EQUAL , self :: CONDITION_GREATER_THAN , self :: CONDITION_LESS_THAN , self :: CONDITION_GREATER_THAN_OR_EQUAL_TO , self :: CONDITION_LESS_THAN_OR_EQUAL_TO , self :: CONDITION_IF_EMPTY , self :: CONDITION_IF_NOT_EXISTS , self :: CONDITION_IS_DEFAULT , ] ; }
|
All Available ConditionInterface Types
|
9,029
|
function filter ( $ key = NULL , $ func = NULL ) { if ( ! $ key ) return array_keys ( $ this -> filter ) ; if ( ! $ func ) return $ this -> filter [ $ key ] ; $ this -> filter [ $ key ] = $ func ; }
|
register token filter
|
9,030
|
protected function seeSuccessData ( $ data = null ) { collect ( $ data ) -> each ( function ( $ value , $ key ) { if ( is_array ( $ value ) ) { $ this -> seeSuccessData ( $ value ) ; } else { $ this -> seeJson ( [ $ key => $ value ] ) ; } } ) ; return $ this ; }
|
Assert that the response data contains given values .
|
9,031
|
protected function getSuccessData ( $ attributes = null ) { $ rawData = $ this -> decodeResponseJson ( ) [ 'data' ] ; if ( is_null ( $ attributes ) ) { return $ rawData ; } elseif ( is_string ( $ attributes ) ) { return array_get ( $ rawData , $ attributes ) ; } $ data = [ ] ; foreach ( $ attributes as $ attribute ) { $ data [ ] = array_get ( $ rawData , $ attribute ) ; } return $ data ; }
|
Decodes JSON response and returns the data .
|
9,032
|
protected function seeError ( string $ error , int $ status = null ) { if ( ! is_null ( $ status ) ) { $ this -> seeStatusCode ( $ status ) ; } if ( $ this -> app -> config -> get ( 'responder.status_code' ) ) { $ this -> seeJson ( [ 'status' => $ status ] ) ; } return $ this -> seeJson ( [ 'success' => false ] ) -> seeJsonSubset ( [ 'error' => [ 'code' => $ error ] ] ) ; }
|
Assert that the response is a valid error response .
|
9,033
|
public function generateRandomPassword ( ) { $ alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789" ; $ pass = array ( ) ; $ alphaLength = strlen ( $ alphabet ) - 1 ; for ( $ i = 0 ; $ i < 8 ; $ i ++ ) { $ n = rand ( 0 , $ alphaLength ) ; $ pass [ ] = $ alphabet [ $ n ] ; } return implode ( $ pass ) ; }
|
Geneate Radmon password .
|
9,034
|
public function isUnique ( $ username , $ email , $ dni = null , $ code = null ) { $ entities = $ this -> getEm ( ) -> getRepository ( "AmulenUserBundle:User" ) -> findByUniques ( $ username , $ email , $ dni , $ code ) ; return count ( $ entities ) <= 0 ; }
|
Check if is unique .
|
9,035
|
public function getAuthToken ( $ user , $ plainPassword , $ firewall , $ roles = array ( ) ) { $ token = new UsernamePasswordToken ( $ user , $ user -> getPlainPassword ( ) , $ firewall , $ roles ) ; $ this -> tokenStorage -> setToken ( $ token ) ; return $ token ; }
|
Get by Code .
|
9,036
|
public function uploadImage ( User $ entity ) { if ( null === $ entity -> getFile ( ) ) { return $ entity ; } $ uploadBaseDir = $ this -> container -> getParameter ( "user_avatar_basedir" ) ; $ uploadDir = $ this -> container -> getParameter ( "user_avatar_dir" ) ; $ filename = $ entity -> getFile ( ) -> getClientOriginalName ( ) ; $ extension = $ entity -> getFile ( ) -> getClientOriginalExtension ( ) ; $ imageName = md5 ( $ filename . time ( ) ) . '.' . $ extension ; $ entity -> setAvatar ( $ uploadDir . $ imageName ) ; $ entity -> getFile ( ) -> move ( $ uploadBaseDir . $ uploadDir , $ imageName ) ; $ entity -> setFile ( null ) ; return $ entity ; }
|
Upload user image .
|
9,037
|
protected function addUpdateExchangeRate ( $ currencyFrom , $ currencyTo , $ rate ) { if ( ! in_array ( $ currencyTo , $ this -> managedCurrencies ) ) { return false ; } $ exchangeRate = $ this -> currencyRateRepository -> findOneBy ( [ 'currencyFrom' => $ currencyFrom , 'currencyTo' => $ currencyTo , ] ) ; if ( null === $ exchangeRate ) { $ exchangeRate = new CurrencyRate ( ) ; $ exchangeRate -> setCurrencyFrom ( $ currencyFrom ) ; $ exchangeRate -> setCurrencyTo ( $ currencyTo ) ; $ exchangeRate -> setExchangeRate ( $ rate ) ; $ this -> helper -> getEntityManager ( ) -> persist ( $ exchangeRate ) ; } else { $ exchangeRate -> setExchangeRate ( $ rate ) ; } return true ; }
|
Adds new rate or updates existing one
|
9,038
|
public function store ( $ path , $ fileId , $ mimeType , $ size ) { $ this -> cache -> put ( 'seaweedfs.' . md5 ( $ path ) , [ 'fid' => $ fileId , 'mimeType' => $ mimeType , 'size' => $ size ] ) ; }
|
Store a path to a seaweedfs file id
|
9,039
|
public function render ( $ view , $ data = [ ] , $ mergeData = [ ] ) { return $ this -> make ( $ view , $ this -> parseData ( $ data ) , $ mergeData ) -> render ( ) ; }
|
Get the rendered content of the view based
|
9,040
|
public function addRecord ( \ Gpupo \ CommonSchema \ ORM \ Entity \ Banking \ Report \ Record $ record ) { $ this -> records [ ] = $ record ; return $ this ; }
|
Add record .
|
9,041
|
public function removeRecord ( \ Gpupo \ CommonSchema \ ORM \ Entity \ Banking \ Report \ Record $ record ) { return $ this -> records -> removeElement ( $ record ) ; }
|
Remove record .
|
9,042
|
private function _check_filter ( $ item , $ filter ) : bool { if ( $ filter ) { if ( is_string ( $ filter ) ) { return strtolower ( substr ( \ is_array ( $ item ) ? $ item [ 'path' ] : $ item , - strlen ( $ filter ) ) ) === strtolower ( $ filter ) ; } if ( is_callable ( $ filter ) ) { return $ filter ( $ item ) ; } } return true ; }
|
Checks if the given files name ends with the given suffix string
|
9,043
|
public function addIcalendarEvent ( \ sb \ ICalendar \ Event $ event ) { $ a = new \ sb \ Email \ Attachment ( ) ; $ a -> mime_type = 'text/calendar;' ; $ a -> setEncoding ( '8bit' ) ; $ a -> name = 'event.ics' ; $ a -> contents = $ event -> __toString ( ) ; $ this -> addAttachment ( $ a ) ; }
|
Add an \ sb \ ICalendar \ Event request
|
9,044
|
public function onBeforeSend ( ) { if ( ! isset ( $ this -> __added_sent_by_stamp ) ) { $ this -> body .= "\n\nSent Using Surebert Mail" . " recorded: \nSending IP: " . \ sb \ Gateway :: $ remote_addr . " \nSending Host: " . \ sb \ Gateway :: $ http_host ; if ( ! empty ( $ this -> body_HTML ) ) { $ this -> body_HTML .= '<br /><br />' . '<span style="font-size:10px;color:#BCBCBC;margin-top:20px;">' . 'Sent Using Surebert Mail:' . '<br />Sending IP:' . \ sb \ Gateway :: $ remote_addr . ' <br />Sending Host: ' . \ sb \ Gateway :: $ http_host . '</span>' ; } $ this -> __added_sent_by_stamp = true ; } return true ; }
|
Fires before sending if returns false then sending does not occur
|
9,045
|
public function send ( $ outbox = null ) { if ( $ outbox instanceof Writer ) { self :: $ outbox = $ outbox ; } elseif ( ! self :: $ outbox ) { self :: $ outbox = new Writer ( ) ; } if ( $ this -> onBeforeSend ( $ this ) !== false ) { self :: $ outbox -> addEmailToOutbox ( $ this ) ; return self :: $ outbox -> send ( ) ; } }
|
Uses sb_Email_Writer to send the email
|
9,046
|
public function map ( array $ params ) { if ( ! isset ( $ params [ 'ientifier' ] ) ) { throw new MissingArgumentException ( 'identifier' ) ; } if ( ! isset ( $ params [ 'primaryKey' ] ) ) { throw new MissingArgumentException ( 'primaryKey' ) ; } if ( ! isset ( $ params [ 'format' ] ) ) { $ params [ 'format' ] = 'json' ; } return $ this -> post ( 'map' , $ params ) ; }
|
Associates a primary key with a user s social identity .
|
9,047
|
public function unmap ( array $ params ) { if ( ! isset ( $ params [ 'ientifier' ] ) ) { throw new MissingArgumentException ( 'identifier' ) ; } if ( ! isset ( $ params [ 'all_identifiers' ] ) ) { throw new MissingArgumentException ( 'all_identifiers' ) ; } if ( ! isset ( $ params [ 'primaryKey' ] ) ) { throw new MissingArgumentException ( 'primaryKey' ) ; } if ( ! isset ( $ params [ 'unlink' ] ) ) { throw new MissingArgumentException ( 'unlink' ) ; } if ( ! isset ( $ params [ 'format' ] ) ) { $ params [ 'format' ] = 'json' ; } return $ this -> post ( 'unmap' , $ params ) ; }
|
Removes an identity provider from a primary key as well as allowing you to optionally unlink your application from the user s account with the provider .
|
9,048
|
public function get ( $ id ) { return $ this -> _sendPayload ( $ this -> _getService ( $ this -> _pageServiceKey ) -> getPageLayout ( $ id ) ) ; }
|
Get page layout details
|
9,049
|
public function setReport ( \ Gpupo \ CommonSchema \ ORM \ Entity \ Banking \ Report \ Report $ report = null ) { $ this -> report = $ report ; return $ this ; }
|
Set report .
|
9,050
|
public function get ( $ name ) { if ( ! isset ( $ this -> items [ $ name ] ) && ! array_key_exists ( $ name , $ this -> items ) && ! $ this -> applyDefaultValue ( $ name ) ) { throw new \ OutOfBoundsException ( sprintf ( 'Undefined data item index: %s.' , $ name ) ) ; } ; return $ this -> items [ $ name ] ; }
|
Gets a value stored in the context data variable .
|
9,051
|
protected function logException ( \ Exception $ exception ) { $ this -> logger -> error ( $ exception -> getMessage ( ) , array ( 'class' => get_class ( $ exception ) , 'message' => $ exception -> getMessage ( ) , 'file' => $ exception -> getMessage ( ) , 'line' => $ exception -> getMessage ( ) , 'command' => $ this -> getName ( ) ) ) ; }
|
Logs an exception to the logger
|
9,052
|
public static function zip ( $ zip , $ check_usps = true ) { $ result = new \ sb \ Validate \ Results ( ) ; $ result -> value = $ zip ; $ result -> is_valid = false ; if ( preg_match ( "/^(\d{5})(-\d{4})*$/" , $ zip ) ) { $ result -> message = "Valid zip code format" ; $ result -> is_valid = true ; if ( $ check_usps ) { $ page = @ file_get_contents ( "https://tools.usps.com/go/ZipLookupResultsAction!input.action?resultMode=2&postalCode=" . substr ( $ zip , 0 , 5 ) ) ; if ( ! $ page ) { $ result -> message .= ' cannot reach USPS site to validate zip code existence' ; } else { preg_match ( "~<p class=\"std-address\">(.*?)</p>~" , $ page , $ city ) ; if ( isset ( $ city [ 1 ] ) ) { $ data = trim ( $ city [ 1 ] ) ; $ result -> state = substr ( $ data , - 2 , 2 ) ; $ result -> city = ucwords ( strtolower ( preg_replace ( "~" . $ result -> state . "$~" , "" , $ data ) ) ) ; $ result -> message .= " for " . $ result -> city . ',' . $ result -> state ; } else { $ result -> message .= " but city not found!" ; $ result -> is_valid = false ; } } } } else { $ result -> message = "Invalid zip code format " ; } return $ result ; }
|
Validates a zip code
|
9,053
|
public static function normalize ( $ risk ) { return ( float ) max ( min ( $ risk , self :: MAXIMUM_RISK ) , self :: MINIMUM_RISK ) ; }
|
Normalize Risk - make sure that risk will be in bound
|
9,054
|
public function listAction ( ) { $ this -> performAccessChecks ( ) ; $ crons = $ this -> cronService -> listCronsStatus ( ) ; $ cronRows = array ( ) ; foreach ( $ crons as $ cron ) { $ cronRows [ ] = array ( 'alias' => $ cron -> getAlias ( ) , 'queued' => $ cron instanceof SmileCron ? ( $ cron -> getQueued ( ) ? $ cron -> getQueued ( ) -> format ( 'd-m-Y H:i' ) : false ) : false , 'started' => $ cron instanceof SmileCron ? ( $ cron -> getStarted ( ) ? $ cron -> getStarted ( ) -> format ( 'd-m-Y H:i' ) : false ) : false , 'ended' => $ cron instanceof SmileCron ? ( $ cron -> getEnded ( ) ? $ cron -> getEnded ( ) -> format ( 'd-m-Y H:i' ) : false ) : false , 'status' => $ cron instanceof SmileCron ? $ cron -> getStatus ( ) : false ) ; } return $ this -> render ( 'SmileEzUICronBundle:cron:tab/status/list.html.twig' , [ 'datas' => $ cronRows ] ) ; }
|
List crons status
|
9,055
|
protected function createValidators ( array $ validators ) { $ this -> availableValidators = [ ] ; foreach ( $ validators as $ name => $ type ) { $ class = '\\Valdi\\Validator\\' . $ type ; $ this -> availableValidators [ $ name ] = new $ class ( ) ; } }
|
Creates instances of the available validators .
|
9,056
|
protected function isValidRule ( $ validator , $ parameters , $ value ) { if ( ! array_key_exists ( $ validator , $ this -> availableValidators ) ) { throw new ValidatorException ( '"' . $ validator . '" not found as available validator.' ) ; } return $ this -> availableValidators [ $ validator ] -> isValid ( $ value , $ parameters ) ? null : $ this -> availableValidators [ $ validator ] -> getInvalidDetails ( ) ; }
|
Validates a single rule .
|
9,057
|
public function isValidValue ( $ rules , $ value ) { $ result = [ ] ; foreach ( $ rules as $ rule ) { $ parameters = $ rule ; $ name = array_shift ( $ parameters ) ; $ valid = $ this -> isValidRule ( $ name , $ parameters , $ value ) ; if ( $ valid !== null ) { $ result [ ] = $ valid ; } } return $ result ; }
|
Validates a value via the given rules .
|
9,058
|
public function isValid ( array $ rules , array $ data ) { $ errors = [ ] ; foreach ( $ rules as $ field => $ fieldRules ) { $ value = isset ( $ data [ $ field ] ) ? $ data [ $ field ] : null ; $ fieldErrors = $ this -> isValidValue ( $ fieldRules , $ value ) ; if ( ! empty ( $ fieldErrors ) ) { $ errors [ $ field ] = $ fieldErrors ; } } return [ 'valid' => count ( $ errors ) === 0 , 'errors' => $ errors ] ; }
|
Performs the actual validation .
|
9,059
|
public function saveToDb ( $ incomingOnly = false ) { $ count = ( $ incomingOnly ) ? $ this -> dbInterface -> executeDataImportIncoming ( ) : $ this -> dbInterface -> executeDataImport ( ) ; return $ count ; }
|
Saves the data to DB using iAccountStatementDbController
|
9,060
|
public function addLoop ( $ data ) { $ length = is_array ( $ data ) || $ data instanceof Countable ? count ( $ data ) : null ; $ parent = Arr :: last ( $ this -> loopsStack ) ; $ this -> loopsStack [ ] = [ 'iteration' => 0 , 'index' => 0 , 'remaining' => isset ( $ length ) ? $ length : null , 'count' => $ length , 'first' => true , 'last' => isset ( $ length ) ? $ length === 1 : null , 'depth' => count ( $ this -> loopsStack ) + 1 , 'parent' => $ parent ? ( object ) $ parent : null , ] ; }
|
Add new loop to the stack .
|
9,061
|
public function incrementLoopIndices ( ) { $ loop = $ this -> loopsStack [ $ index = count ( $ this -> loopsStack ) - 1 ] ; $ this -> loopsStack [ $ index ] = array_merge ( $ this -> loopsStack [ $ index ] , [ 'iteration' => $ loop [ 'iteration' ] + 1 , 'index' => $ loop [ 'iteration' ] , 'first' => $ loop [ 'iteration' ] === 0 , 'remaining' => isset ( $ loop [ 'count' ] ) ? $ loop [ 'remaining' ] - 1 : null , 'last' => isset ( $ loop [ 'count' ] ) ? $ loop [ 'iteration' ] === $ loop [ 'count' ] - 1 : null , ] ) ; }
|
Increment the top loop s indices .
|
9,062
|
public function evaluate ( $ actual ) { $ matcherResult = $ this -> matcher -> match ( $ actual ) ; $ expected = $ this -> negated ? false : true ; $ result = $ matcherResult === $ expected ; return new Result ( $ actual , $ this -> negated , $ this -> matcher , $ result ) ; }
|
Evaluate the value of actual .
|
9,063
|
static function parseMobileNumber ( $ number ) { $ numerics = static :: extractNumerics ( $ number ) ; $ countryCode = '' ; $ short = static :: right ( $ numerics , 10 , $ countryCode ) ; $ carriercode = '' ; $ number = static :: right ( $ short , 7 , $ carrierCode ) ; return compact ( 'countryCode' , 'carrierCode' , 'number' ) ; }
|
Parse mobile number
|
9,064
|
static function arrayExtract ( array $ keys , array $ array , array $ callbacks = [ ] ) { $ extracted = [ ] ; foreach ( $ keys as $ key ) { if ( array_key_exists ( $ key , $ array ) ) { $ item = $ array [ $ key ] ; if ( isset ( $ callbacks [ $ key ] ) && is_callable ( $ callbacks [ $ key ] ) ) { $ item = call_user_func_array ( $ callbacks [ $ key ] , [ $ item ] ) ; } $ extracted [ $ key ] = $ item ; } } return $ extracted ; }
|
Extract array from array with keys
|
9,065
|
public function onLayoutBoxFormInit ( FormEvent $ event ) { $ builder = $ event -> getFormBuilder ( ) ; $ form = $ event -> getForm ( ) ; $ configurators = $ this -> container -> get ( 'layout_box.configurator.collection' ) -> all ( ) ; $ resource = $ event -> getResource ( ) ; $ boxSettings = $ resource -> getSettings ( ) ; foreach ( $ configurators as $ configurator ) { if ( $ configurator instanceof LayoutBoxConfiguratorInterface ) { $ defaults = [ ] ; if ( $ resource -> getBoxType ( ) == $ configurator -> getType ( ) ) { $ defaults = $ boxSettings ; } $ configurator -> addFormFields ( $ builder , $ form , $ defaults ) ; } } }
|
Adds configurator fields to main layout box edit form . Loops through all configurators renders the fieldset and sets default data
|
9,066
|
public function onLayoutBoxPreUpdate ( EntityEvent $ event ) { $ resource = $ event -> getEntity ( ) ; if ( $ resource instanceof LayoutBox ) { $ request = $ this -> getRequestHelper ( ) -> getCurrentRequest ( ) ; $ settings = $ this -> getBoxSettingsFromRequest ( $ request ) ; $ settings = $ this -> mergeUnmodifiedSettings ( $ resource -> getSettings ( ) , $ settings ) ; $ resource -> setSettings ( $ settings ) ; } }
|
Sets resource settings fetched from fieldset corresponding to selected box type
|
9,067
|
public function export ( $ product ) { $ files = $ product -> generateFiles ( ) ; mkdir ( $ this -> target , 0777 , true ) ; foreach ( $ files as $ file ) if ( ! $ file -> getContent ( ) -> copy ( fphp \ Helper \ Path :: join ( $ this -> target , $ file -> getTarget ( ) ) ) ) throw new LocalExporterException ( "could not copy file \"{$file->getTarget()}\"" ) ; }
|
Exports a product in the local filesystem . Every generated file is copied to the filesystem at its target path .
|
9,068
|
protected function validatePassword ( LoginForm & $ loginForm ) { return [ 'password' , function ( $ attribute ) use ( & $ loginForm ) { if ( $ loginForm -> user === null || ! PasswordHelper :: validate ( $ loginForm -> password , $ loginForm -> user -> password_hash ) ) { $ loginForm -> addError ( $ attribute , Yii :: t ( 'users' , 'Invalid login or password' ) ) ; } } ] ; }
|
Adds password validation rule for login scenario
|
9,069
|
protected function inactiveUsers ( LoginForm & $ loginForm ) { if ( UsersModule :: module ( ) -> allowLoginInactiveAccounts === false ) { return [ ] ; } return [ 'username' , function ( $ attribute ) use ( & $ loginForm ) { if ( $ loginForm -> user !== null && $ loginForm -> user -> is_active === false ) { $ loginForm -> addError ( $ attribute , Yii :: t ( 'users' , 'You need to confirm your email address' ) ) ; } } ] ; }
|
Adds validation rule to not accept inactive users if such feature is toggled on in module configuration .
|
9,070
|
public function tag ( $ tag , $ attr = null , $ content = null , $ close = false ) { $ tag = strtolower ( $ tag ) ; if ( ! empty ( $ attr ) && is_array ( $ attr ) ) { $ attr = $ this -> Attr -> attr ( $ attr ) ; } if ( $ close ) { return sprintf ( '<%s%s>%s</%1$s>' , $ tag , $ attr , $ content ) ; } else { return sprintf ( '<%s%s>' , $ tag , $ attr ) ; } }
|
render a tag
|
9,071
|
public function processList ( $ list , $ subListType = 'ul' ) { $ out = '' ; foreach ( $ list as $ key => $ value ) { if ( is_array ( $ value ) && ( isset ( $ value [ 'list' ] ) || isset ( $ value [ 'attr' ] ) ) ) { $ attr = ( isset ( $ value [ 'attr' ] ) ) ? $ value [ 'attr' ] : null ; $ listAttr = ( isset ( $ value [ 'listAttr' ] ) ) ? $ value [ 'listAttr' ] : null ; $ subList = ( isset ( $ value [ 'list' ] ) ) ? $ this -> { $ subListType } ( $ value [ 'list' ] , $ listAttr ) : '' ; $ out .= $ this -> tag ( 'li' , $ attr , $ key . $ subList , true ) ; } elseif ( is_array ( $ value ) ) { $ out .= $ this -> tag ( 'li' , null , $ key . $ this -> { $ subListType } ( $ value ) , true ) ; } else { $ out .= $ this -> tag ( 'li' , null , $ value , true ) ; } } return $ out ; }
|
process list items
|
9,072
|
public function image ( $ src , $ attr = array ( ) ) { $ src = $ this -> Assets -> getImage ( $ src ) ; $ attr [ 'src' ] = $ src ; return $ this -> tag ( 'img' , $ attr ) ; }
|
create an image
|
9,073
|
public function style ( $ src , $ attr = array ( ) ) { $ src = $ this -> Assets -> getStyle ( $ src ) ; $ attr [ 'href' ] = $ src ; $ attr = array_merge ( array ( 'media' => 'screen' , 'rel' => 'stylesheet' , 'type' => 'text/css' ) , $ attr ) ; return $ this -> tag ( 'link' , $ attr ) ; }
|
create a style link
|
9,074
|
public function script ( $ src , $ attr = array ( ) ) { $ src = $ this -> Assets -> getScript ( $ src ) ; $ attr [ 'src' ] = $ src ; return $ this -> tag ( 'script' , $ attr , '' , true ) ; }
|
create a script tag
|
9,075
|
public function setRouter ( $ Router ) { if ( ! is_object ( $ Router ) || ! $ Router instanceof Router ) { throw new \ InvalidArgumentException ( 'The Router Interface must be a valid Router Object' ) ; } $ this -> Router = $ Router ; return true ; }
|
check and set the router interface
|
9,076
|
public function setAssets ( $ Assets ) { if ( ! is_object ( $ Assets ) || ! $ Assets instanceof Assets ) { throw new \ InvalidArgumentException ( 'The Assets Interface must be a valid Assets Object' ) ; } $ this -> Assets = $ Assets ; return true ; }
|
check and set the Asset interface
|
9,077
|
public function setForm ( $ Form ) { if ( ! is_object ( $ Form ) || ! $ Form instanceof Helpers \ Form ) { throw new \ InvalidArgumentException ( 'The Form Object must be a valid Helpers\Form Object' ) ; } $ this -> Form = $ Form ; return true ; }
|
check and set the Form Object
|
9,078
|
public function removePayment ( \ Gpupo \ CommonSchema \ ORM \ Entity \ Trading \ Payment \ Payment $ payment ) { return $ this -> payments -> removeElement ( $ payment ) ; }
|
Remove payment .
|
9,079
|
public function baseUrl ( ) { if ( ! $ this -> baseUrl ) { $ this -> baseUrl = $ this -> request -> getScheme ( ) . '://' . $ this -> request -> getHttpHost ( ) ; } return $ this -> baseUrl ; }
|
Gets the base url
|
9,080
|
public function absoluteUrl ( $ uri = null , $ args = null ) { if ( isset ( $ uri ) ) { $ uri = '/' . ltrim ( $ uri , "/" ) ; return $ this -> baseUrl ( ) . $ this -> url -> get ( $ uri , $ args ) ; } else { return $ this -> baseUrl ( ) . $ this -> url -> getBaseUri ( ) ; } }
|
Gets absolute url
|
9,081
|
public function ltrim ( $ str , $ charlist = null ) { return isset ( $ charlist ) ? ltrim ( $ str , $ charlist ) : ltrim ( $ str ) ; }
|
left trim string
|
9,082
|
public function rtrim ( $ str , $ charlist = null ) { return isset ( $ charlist ) ? rtrim ( $ str , $ charlist ) : rtrim ( $ str ) ; }
|
right trim string
|
9,083
|
private function zSignatureExists ( $ dom ) { $ signature = $ dom -> getElementsByTagName ( 'Signature' ) -> item ( 0 ) ; if ( ! isset ( $ signature ) ) { return false ; } return true ; }
|
signatureExists Check se o xml possi a tag Signature .
|
9,084
|
private function zLeaveParam ( ) { $ this -> pfxCert = '' ; $ this -> pubKey = '' ; $ this -> priKey = '' ; $ this -> certKey = '' ; $ this -> pubKeyFile = '' ; $ this -> priKeyFile = '' ; $ this -> certKeyFile = '' ; $ this -> expireTimestamp = '' ; }
|
zLeaveParam Limpa os parametros da classe .
|
9,085
|
public function getPackage ( ) { $ inheritedElement = $ this -> getInheritedElement ( ) ; if ( $ this -> package instanceof PackageDescriptor && ! ( $ this -> package -> getName ( ) === '\\' && $ inheritedElement ) ) { return $ this -> package ; } if ( $ inheritedElement instanceof DescriptorAbstract ) { return $ inheritedElement -> getPackage ( ) ; } return null ; }
|
Returns the package name for this element .
|
9,086
|
protected function buildMethods ( ) { $ refl = new \ ReflectionClass ( $ this ) ; $ enterMethods = [ ] ; $ leaveMethods = [ ] ; foreach ( $ refl -> getMethods ( ) as $ method ) { $ name = $ method -> getName ( ) ; if ( preg_match ( '/^(enter|leave).+/' , $ name ) && ! preg_match ( '/^(enter|leave)Node$/' , $ name ) ) { $ params = $ method -> getParameters ( ) ; if ( $ params && $ params [ 0 ] -> getClass ( ) ) { $ nodeType = $ params [ 0 ] -> getClass ( ) -> getName ( ) ; if ( Text :: startsWith ( $ name , 'enter' ) ) { $ enterMethods [ $ nodeType ] [ ] = $ name ; } else { $ leaveMethods [ $ nodeType ] [ ] = $ name ; } } } } self :: $ enterMethods [ get_class ( $ this ) ] = $ enterMethods ; self :: $ leaveMethods [ get_class ( $ this ) ] = $ leaveMethods ; }
|
collect all rule method according to node type of parameter
|
9,087
|
protected function setDefaults ( array $ defaultOptions = array ( ) ) { $ defaultOptions = array_merge ( array ( 'depth' => null , 'ancestorCurrencyDepth' => null , 'currentClass' => 'active' , 'ancestorClass' => 'active' , 'firstClass' => null , 'lastClass' => null ) , $ defaultOptions ) ; parent :: setDefaults ( $ defaultOptions ) ; }
|
Overwriting some options - classes etc .
|
9,088
|
public function write ( $ data ) { $ post_date_string = $ data [ 'post_date' ] -> format ( 'Y-m-d H:i:s' ) ; $ slug = $ this -> generateSlug ( $ data [ 'title' ] ) ; $ filename = $ data [ 'post_date' ] -> format ( 'Y-m-d' ) . '-' . $ slug ; $ headerData = [ 'title' => $ data [ 'title' ] , 'date' => $ post_date_string , 'layout' => 'post' , 'slug' => $ slug , 'categories' => $ data [ 'categories' ] , 'tags' => $ data [ 'tags' ] , ] ; $ dumper = new YamlDumper ( ) ; $ header = '---' . PHP_EOL . $ dumper -> dump ( $ headerData , 2 ) . '---' . PHP_EOL ; $ filename = $ this -> destinationFolder . $ filename ; if ( $ this -> isMarkdownEnabled ( ) ) { $ filename .= '.md' ; $ data [ 'content' ] = $ this -> toMarkdown ( $ data [ 'content' ] ) ; } else { $ filename .= '.html' ; } file_put_contents ( $ filename , $ header . PHP_EOL . $ data [ 'content' ] ) ; }
|
Write out a set of data into a file
|
9,089
|
static function parse ( string $ url , ? int $ preferredFormat = self :: ABSOLUTE ) { $ components = parse_url ( $ url ) ; if ( $ components === false ) { throw new InvalidUrlException ( sprintf ( 'The given URL "%s" is invalid' , $ url ) ) ; } $ query = [ ] ; if ( isset ( $ components [ 'query' ] ) ) { parse_str ( $ components [ 'query' ] , $ query ) ; } return new static ( $ components [ 'scheme' ] ?? null , $ components [ 'host' ] ?? null , $ components [ 'port' ] ?? null , $ components [ 'path' ] ?? '' , $ query , $ components [ 'fragment' ] ?? null , $ preferredFormat ) ; }
|
Parse an URL
|
9,090
|
function getFullHost ( ) : ? string { if ( $ this -> host === null ) { return null ; } $ fullHost = $ this -> host ; if ( $ this -> port !== null ) { $ fullHost .= ':' . $ this -> port ; } return $ fullHost ; }
|
Get host name including the port if defined
|
9,091
|
function add ( array $ parameters ) : void { foreach ( $ parameters as $ parameter => $ value ) { $ this -> query [ $ parameter ] = $ value ; } }
|
Add multiple query parameters
|
9,092
|
function build ( ) : string { if ( $ this -> host !== null && $ this -> preferredFormat === static :: ABSOLUTE ) { return $ this -> buildAbsolute ( ) ; } else { return $ this -> buildRelative ( ) ; } }
|
Build an absolute or relative URL
|
9,093
|
function buildAbsolute ( ) : string { $ output = '' ; if ( $ this -> host === null ) { throw new IncompleteUrlException ( 'No host specified' ) ; } if ( $ this -> scheme !== null ) { $ output .= $ this -> scheme ; $ output .= '://' ; } else { $ output .= '//' ; } $ output .= $ this -> getFullHost ( ) ; if ( $ this -> path !== '' && $ this -> path [ 0 ] !== '/' ) { $ output .= '/' ; } $ output .= $ this -> buildRelative ( ) ; return $ output ; }
|
Build an absolute URL
|
9,094
|
function buildRelative ( ) : string { $ output = '' ; $ output .= $ this -> path ; if ( $ this -> query ) { $ output .= '?' ; $ output .= $ this -> getQueryString ( ) ; } if ( $ this -> fragment !== null ) { $ output .= '#' ; $ output .= $ this -> fragment ; } return $ output ; }
|
Build a relative URL
|
9,095
|
public function container ( $ container = 'default' ) { if ( ! isset ( $ this -> containers [ $ container ] ) ) { $ this -> containers [ $ container ] = new Container ( $ container ) ; } return $ this -> containers [ $ container ] ; }
|
Retrieve the requested asset container object .
|
9,096
|
public function preparePharCacert ( $ md5Check = true ) { $ from = __DIR__ . '/Resources/cacert.pem' ; $ certFile = sys_get_temp_dir ( ) . '/guzzle-cacert.pem' ; if ( ! file_exists ( $ certFile ) && ! copy ( $ from , $ certFile ) ) { throw new RuntimeException ( "Could not copy {$from} to {$certFile}: " . var_export ( error_get_last ( ) , true ) ) ; } elseif ( $ md5Check ) { $ actualMd5 = md5_file ( $ certFile ) ; $ expectedMd5 = trim ( file_get_contents ( "{$from}.md5" ) ) ; if ( $ actualMd5 != $ expectedMd5 ) { throw new RuntimeException ( "{$certFile} MD5 mismatch: expected {$expectedMd5} but got {$actualMd5}" ) ; } } return $ certFile ; }
|
Copy the cacert . pem file from the phar if it is not in the temp folder and validate the MD5 checksum
|
9,097
|
static protected function findRecursiveCallback ( ezcBaseFileFindContext $ context , $ sourceDir , $ fileName , $ fileInfo ) { if ( $ fileInfo [ 'mode' ] & 0x4000 ) { return ; } $ context -> elements [ ] = $ sourceDir . DIRECTORY_SEPARATOR . $ fileName ; $ context -> count ++ ; $ context -> size += $ fileInfo [ 'size' ] ; }
|
This is the callback used by findRecursive to collect data .
|
9,098
|
static public function walkRecursive ( $ sourceDir , array $ includeFilters = array ( ) , array $ excludeFilters = array ( ) , $ callback , & $ callbackContext ) { if ( ! is_dir ( $ sourceDir ) ) { throw new ezcBaseFileNotFoundException ( $ sourceDir , 'directory' ) ; } $ elements = array ( ) ; $ d = @ dir ( $ sourceDir ) ; if ( ! $ d ) { throw new ezcBaseFilePermissionException ( $ sourceDir , ezcBaseFileException :: READ ) ; } while ( ( $ entry = $ d -> read ( ) ) !== false ) { if ( $ entry == '.' || $ entry == '..' ) { continue ; } $ fileInfo = @ stat ( $ sourceDir . DIRECTORY_SEPARATOR . $ entry ) ; if ( ! $ fileInfo ) { $ fileInfo = array ( 'size' => 0 , 'mode' => 0 ) ; } if ( $ fileInfo [ 'mode' ] & 0x4000 ) { try { call_user_func_array ( $ callback , array ( $ callbackContext , $ sourceDir , $ entry , $ fileInfo ) ) ; $ subList = self :: walkRecursive ( $ sourceDir . DIRECTORY_SEPARATOR . $ entry , $ includeFilters , $ excludeFilters , $ callback , $ callbackContext ) ; $ elements = array_merge ( $ elements , $ subList ) ; } catch ( ezcBaseFilePermissionException $ e ) { } } else { $ ok = true ; foreach ( $ includeFilters as $ filter ) { if ( ! preg_match ( $ filter , $ sourceDir . DIRECTORY_SEPARATOR . $ entry ) ) { $ ok = false ; break ; } } foreach ( $ excludeFilters as $ filter ) { if ( preg_match ( $ filter , $ sourceDir . DIRECTORY_SEPARATOR . $ entry ) ) { $ ok = false ; break ; } } if ( $ ok ) { call_user_func ( $ callback , $ callbackContext , $ sourceDir , $ entry , $ fileInfo ) ; $ elements [ ] = $ sourceDir . DIRECTORY_SEPARATOR . $ entry ; } } } sort ( $ elements ) ; return $ elements ; }
|
Walks files and directories recursively on a file system
|
9,099
|
static public function findRecursive ( $ sourceDir , array $ includeFilters = array ( ) , array $ excludeFilters = array ( ) , & $ statistics = null ) { if ( ! is_array ( $ statistics ) || ! array_key_exists ( 'size' , $ statistics ) || ! array_key_exists ( 'count' , $ statistics ) ) { $ statistics [ 'size' ] = 0 ; $ statistics [ 'count' ] = 0 ; } $ context = new ezcBaseFileFindContext ; self :: walkRecursive ( $ sourceDir , $ includeFilters , $ excludeFilters , array ( 'ezcBaseFile' , 'findRecursiveCallback' ) , $ context ) ; $ statistics [ 'size' ] = $ context -> size ; $ statistics [ 'count' ] = $ context -> count ; sort ( $ context -> elements ) ; return $ context -> elements ; }
|
Finds files recursively on a file system
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.