idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
43,500
protected function parseResponse ( Response $ response ) { $ contentType = explode ( ';' , $ response -> getHeader ( 'content-type' ) ) [ 0 ] ; switch ( $ contentType ) { case 'application/json' : case 'application/vnd.api+json' : return $ response -> json ( ) ; case 'application/xml' : return $ response -> xml ( ) ; } throw new RuntimeException ( "Unsupported returned content-type [$contentType]" ) ; }
Parse the returned response .
43,501
function attachToEvent ( iEvent $ event ) { if ( \ Poirot \ isCommandLine ( ) ) return $ this ; $ self = $ this ; $ event -> on ( EventHeapOfSapi :: EVENT_APP_MATCH_REQUEST , function ( ) use ( $ self ) { $ self -> _assertAccess ( ) ; } ) ; return $ this ; }
Attach To Event
43,502
function setBlockList ( $ list ) { if ( $ list instanceof \ Traversable ) $ list = \ Poirot \ Std \ cast ( $ list ) -> toArray ( ) ; if ( ! is_array ( $ list ) ) throw new \ InvalidArgumentException ( sprintf ( 'List must instanceof Traversable or array; given (%s).' , \ Poirot \ Std \ flatten ( $ list ) ) ) ; $ this -> blockList = $ list ; return $ this ; }
Set IP Block List
43,503
public function setViewport ( $ width = 'device-width' , $ initial_scale = '1' , $ user_scalable = '' , $ minimum_scale = '' , $ maximum_scale = '' ) { $ tag = [ 'name' => 'viewport' , 'content' => 'width=' . $ width . ', initial-scale=' . $ initial_scale ] ; if ( $ user_scalable ) { $ tag [ 'content' ] .= ', user-scalable=' . $ user_scalable ; } if ( $ minimum_scale ) { $ tag [ 'content' ] .= ', minimum-scale=' . $ minimum_scale ; } if ( $ maximum_scale ) { $ tag [ 'content' ] .= ', maximum_scale=' . $ maximum_scale ; } $ this -> tags [ 'viewport' ] = $ tag ; }
Sets vieport tag
43,504
public function createConnection ( $ parameters ) { $ connection = new \ PDO ( 'mysql:host=' . $ parameters [ 'host' ] . ';dbname=' . $ parameters [ 'database' ] , $ parameters [ 'username' ] , $ parameters [ 'password' ] ) ; if ( isset ( $ parameters [ 'charset' ] ) ) { $ connection -> exec ( 'SET CHARACTER SET ' . $ parameters [ 'charset' ] ) ; } return $ connection ; }
Creates a MySql Connection
43,505
protected static function fetch ( ) { $ command = array ( 'LINUX' => new Commands \ Linux ( ) , 'MAC' => new Commands \ Mac ( ) , 'WIN' => new Commands \ Windows ( ) ) ; $ instance = 'No valid desktop notifier found.' ; if ( $ command [ 'WIN' ] -> isAvailable ( ) ) { $ instance = $ command [ 'WIN' ] ; } elseif ( $ command [ 'LINUX' ] -> isAvailable ( ) ) { $ instance = $ command [ 'LINUX' ] ; } elseif ( $ command [ 'MAC' ] -> isAvailable ( ) ) { $ instance = $ command [ 'MAC' ] ; } if ( is_string ( $ instance ) ) { throw new \ RuntimeException ( $ instance ) ; } return $ instance ; }
Fetches an instance by checking for ability .
43,506
public function getComposer ( $ required = true , $ disablePlugins = false ) { if ( null === $ this -> composer ) { if ( $ this -> composerFactory ) { $ this -> composer = call_user_func ( $ this -> composerFactory , $ required , $ disablePlugins ) ; } if ( $ required && ! $ this -> composer ) { throw new \ RuntimeException ( 'You must define a factory closure for wrapped commands to retrieve the ' . 'composer instance.' ) ; } } return $ this -> composer ; }
Retrieve the composer instance .
43,507
public function getErrors ( $ attribute = null ) { $ itemErrors = [ ] ; foreach ( $ this -> getItems ( ) as $ item ) { if ( $ item -> hasErrors ( $ attribute ) ) { $ itemErrors [ $ this -> getItemId ( $ item ) ] = $ item -> getErrors ( $ attribute ) ; } } return array_merge ( $ this -> _traitGetErrors ( $ attribute ) , $ itemErrors ) ; }
Merge errors from all
43,508
public function isNameAvailable ( $ name , $ fields = array ( ) ) { $ fields = ( object ) $ fields ; return ! $ this -> getMapper ( ) -> isNameExists ( $ name . ( empty ( $ fields -> type ) ? '' : '.' . $ fields -> type ) ) ; }
Find a structure is available
43,509
public function createBuilder ( $ type = 'job' , array $ initOptions = array ( ) , array $ execOptions = array ( ) ) { $ name = $ type instanceof JobTypeInterface || $ type instanceof ResolvedJob ? $ type -> getName ( ) : $ type ; return $ this -> createNamedBuilder ( $ name , $ type , $ initOptions , $ execOptions ) ; }
Create a builder
43,510
public function resolveType ( JobTypeInterface $ type ) { $ parentType = $ type -> getParent ( ) ; if ( $ parentType instanceof JobTypeInterface ) { $ parentType = $ this -> resolveType ( $ parentType ) ; } elseif ( null !== $ parentType ) { $ parentType = $ this -> registry -> getType ( $ parentType ) ; } return $ this -> createResolvedType ( $ type , $ parentType ) ; }
Creates wrapper for combination of JobType and JobConnector
43,511
public static function set ( $ file , $ command , $ database ) { $ database = $ database ? 'true' : 'false' ; $ txt = "<?php\n\nnamespace Vinala\App\Support\Lumos;\n\n" ; $ txt .= "use Vinala\Kernel\Console\Command\Commands;\n\n" ; $ txt .= self :: docs ( "$file Command" ) ; $ txt .= " class $file extends Commands\n{\n\t" ; $ txt .= "\n\t/**\n\t * The key of the console command.\n\t *\n\t * @var string\n\t */\n\tprotected " . '$key = ' . "'$command';\n\n" ; $ txt .= "\n\t/**\n\t * The console command description.\n\t *\n\t * @var string\n\t */\n\tprotected " . '$description = ' . "'say hello to the world';\n\n" ; $ txt .= "\n\t/**\n\t * True if the command will use database.\n\t *\n\t * @var bool\n\t */\n\tprotected " . '$database = ' . "$database ;\n\n" ; $ txt .= "\n\t/**\n\t * Execute the console command.\n\t *\n\t * @return mixed\n\t */\n\tpublic function handle()\n\t{\n\t\t " . '$this->line("What\'s up!"); ' . "\n\t}" ; $ txt .= "\n}" ; return $ txt ; }
prepare the text to put in command file .
43,512
public function alias ( $ alias = null ) { if ( $ alias === null ) { return $ this -> _alias ; } $ this -> _alias = $ alias ; return $ this ; }
Get or set the alias .
43,513
public function name ( $ name = null ) { if ( $ name === null ) { return $ name ; } $ this -> _name = $ name ; return $ this ; }
Get or set the name .
43,514
public function shortName ( $ name = null ) { if ( $ name === null ) { return $ this -> _nameShort ; } $ this -> _nameShort = $ name ; return $ this ; }
Get or set the short name .
43,515
public function icon ( $ icon = null ) { if ( $ icon === null ) { return $ this -> _icon ; } $ this -> _icon = $ icon ; return $ this ; }
Get or set the icon class .
43,516
public function url ( $ url = null ) { if ( $ url === null ) { return $ this -> _url ; } $ this -> _url = $ url ; return $ this ; }
Get or set the url .
43,517
public function parent ( $ parent = null ) { if ( $ parent === null ) { return $ this -> _parent ; } $ this -> _parent = $ parent ; return $ this ; }
Get or set the parent menu alias .
43,518
public function matchAction ( $ matchAction = null ) { if ( $ matchAction === null ) { return $ this -> _matchAction ; } $ this -> _matchAction = $ matchAction ; return $ this ; }
Get or set match action .
43,519
public function doNotMatchAction ( array $ action , $ reset = false ) { if ( $ reset ) { $ this -> _doNotMatchAction = [ ] ; } if ( ! empty ( $ action ) ) { $ this -> _doNotMatchAction [ ] = $ action ; } return $ this ; }
Add an action which this menu item should not match for .
43,520
public function getRules ( ) { $ rules = empty ( $ this -> rules ) ? $ this -> rules ( $ this -> request , $ this -> params ) : $ this -> rules ; return $ this -> explodeRules ( $ rules ) ; }
get the rules from child class
43,521
public function removeRequired ( ) { foreach ( $ this -> getRules ( ) as $ key => $ rules ) { $ newRules [ $ key ] = preg_grep ( "/^required/" , $ rules , PREG_GREP_INVERT ) ; } $ this -> rules = $ newRules ; return $ this ; }
remove required rule from rules function
43,522
public function getDbValues ( array $ input = [ ] , $ mappings = [ ] ) { $ response = [ ] ; foreach ( $ mappings as $ inputKey => $ dbValue ) { if ( is_array ( $ input ) && array_get ( $ input , $ inputKey ) !== null ) { $ value = array_get ( $ input , $ inputKey ) ; if ( $ value instanceof UploadedFile ) { array_set ( $ response , $ dbValue , $ value ) ; } elseif ( is_array ( $ value ) ) { if ( class_exists ( $ mappings [ $ inputKey ] [ 'class' ] ) ) { $ class = new $ mappings [ $ inputKey ] [ 'class' ] ( $ this -> app ) ; foreach ( $ value as $ v ) { $ response [ $ mappings [ $ inputKey ] [ 'key' ] ] [ ] = $ this -> getDbValues ( $ v , $ class -> mappings ( ) ) ; } } else { array_set ( $ response , $ dbValue , $ value ) ; } } else { array_set ( $ response , $ dbValue , ( is_bool ( $ value ) ? $ value : trim ( $ value ) ) ) ; } } } return $ response ; }
conver given array keys to mapper keys
43,523
public function findTreeItem ( $ id , MapperTreeItemInterface $ item ) { if ( $ id === $ item -> getId ( ) ) { return $ item ; } foreach ( $ item -> getChildren ( ) as $ child ) { if ( null !== $ treeItem = $ this -> findTreeItem ( $ id , $ child ) ) { return $ treeItem ; } } return null ; }
Find tree item by id .
43,524
protected function getURLData ( string $ driveUrl ) : array { if ( preg_match ( '~^(https?://)?(drive|docs)\.google\.[a-z]+/.*(/d/|/folders/|[\?&]id=)([a-z0-9\-_]{20,})([/?&#]|$)~i' , $ driveUrl , $ matches ) ) { return [ 'type' => 'google-drive' , 'id' => $ matches [ 4 ] ] ; } if ( preg_match ( '~^(https?://)?[a-z0-9.@\-_\x{0080}-\x{FFFF}]+(:[0-9]+)?(/|$)~iu' , $ driveUrl , $ matches ) ) { return [ 'type' => 'http' , 'driveUrl' => ( $ matches [ 1 ] ? '' : 'http://' ) . $ driveUrl ] ; } return [ 'type' => 'unknown' ] ; }
Gets a URL type and data
43,525
protected function writeGoogleDriveFolderData ( OutputInterface $ output , \ Google_Service_Drive $ drive , \ Google_Service_Drive_DriveFile $ folder ) { $ output -> writeln ( '<info>The URL is a Google Drive folder</info>' ) ; $ output -> writeln ( 'Name: ' . $ folder -> getName ( ) ) ; $ output -> writeln ( 'Content:' ) ; $ pageToken = null ; do { $ children = $ drive -> files -> listFiles ( [ 'pageSize' => 1000 , 'pageToken' => $ pageToken , 'q' => "'{$folder->getId()}' in parents" , 'fields' => 'nextPageToken, files(id,name,mimeType)' ] ) ; foreach ( $ children as $ child ) { $ output -> writeln ( ' - A ' . ( $ child -> getMimeType ( ) === GoogleAPIClient :: MIME_TYPE_DRIVE_FOLDER ? 'folder' : 'file' ) . '. Name: ' . $ child -> getName ( ) ) ; } $ pageToken = $ children -> getNextPageToken ( ) ; } while ( $ pageToken ) ; }
Prints a URL ping result as if the result is a Google Drive folder
43,526
protected function writeGoogleSheetData ( OutputInterface $ output , \ Google_Service_Sheets $ service , \ Google_Service_Drive_DriveFile $ spreadsheet ) { $ output -> writeln ( '<info>The URL is a Google Sheets file</info>' ) ; $ output -> writeln ( 'Name: ' . $ spreadsheet -> getName ( ) ) ; $ spreadsheetData = $ service -> spreadsheets -> get ( $ spreadsheet -> getId ( ) , [ 'includeGridData' => false ] ) ; $ sheetsNames = [ ] ; foreach ( $ spreadsheetData -> getSheets ( ) as $ sheet ) { $ sheetsNames [ ] = $ sheet -> getProperties ( ) -> getTitle ( ) ; } if ( $ sheetsNames ) { $ output -> writeln ( 'Sheets: ' . implode ( ', ' , $ sheetsNames ) ) ; } else { $ output -> writeln ( 'The file has no sheets' ) ; return ; } $ spreadsheetData = $ service -> spreadsheets -> get ( $ spreadsheet -> getId ( ) , [ 'includeGridData' => true , 'ranges' => [ 'A1:E5' ] ] ) ; $ output -> writeln ( 'A piece of the first sheet content:' ) ; $ this -> writeGoogleSheetTable ( $ output , $ spreadsheetData -> getSheets ( ) [ 0 ] ) ; }
Prints a URL ping result as if the result is a Google Sheets file
43,527
protected function writeGoogleSheetTable ( OutputInterface $ output , \ Google_Service_Sheets_Sheet $ sheet ) { $ table = new Table ( $ output ) ; $ merges = $ sheet -> getMerges ( ) ; foreach ( $ sheet -> getData ( ) [ 0 ] -> getRowData ( ) as $ rowIndex => $ sheetRow ) { $ tableRow = [ ] ; foreach ( $ sheetRow -> getValues ( ) as $ columnIndex => $ sheetCell ) { $ colspan = $ rowspan = 1 ; foreach ( $ merges as $ merge ) { if ( $ columnIndex >= $ merge -> getStartColumnIndex ( ) && $ columnIndex < $ merge -> getEndColumnIndex ( ) && $ rowIndex >= $ merge -> getStartRowIndex ( ) && $ rowIndex < $ merge -> getEndRowIndex ( ) ) { if ( $ columnIndex === $ merge -> getStartColumnIndex ( ) && $ rowIndex === $ merge -> getStartRowIndex ( ) ) { $ colspan = $ merge -> getEndColumnIndex ( ) - $ columnIndex ; $ rowspan = $ merge -> getEndRowIndex ( ) - $ rowIndex ; break ; } else { continue 2 ; } } } $ tableRow [ ] = new TableCell ( ( string ) $ sheetCell -> getFormattedValue ( ) , [ 'colspan' => $ colspan , 'rowspan' => $ rowspan ] ) ; } $ table -> addRow ( $ tableRow ) ; } $ table -> render ( ) ; }
Prints a Google Sheet to a console output as a table
43,528
public function getIterator ( ) : \ Generator { $ line = '' ; foreach ( $ this -> readIterator as $ content ) { $ parts = explode ( $ this -> delimiter , $ content ) ; $ partCount = \ count ( $ parts ) ; if ( $ partCount > 1 ) { foreach ( $ parts as $ i => $ part ) { if ( $ i === 0 ) { yield $ line . $ part ; continue ; } if ( $ i === $ partCount - 1 ) { $ line = $ part ; continue ; } yield $ part ; } continue ; } $ line .= $ content ; } yield $ line ; }
Generates parts of an iterator split by the specified delimiter .
43,529
public static function buildHtmlElement ( $ name , array $ attributes = [ ] , $ content = null , $ closeEmptyTag = true , array $ cssClasses = [ ] ) : string { $ html = '<' . $ name . self :: buildAttrs ( $ attributes , $ cssClasses ) ; if ( $ content !== null ) { $ html .= '>' . $ content . '</' . $ name . '>' ; } else { $ html .= $ closeEmptyTag ? ' />' : '>' ; } return $ html ; }
Build an html element
43,530
public static function buildHtmlScript ( $ script , array $ attributes = [ ] ) : string { $ scriptCleaned = trim ( $ script ) ; if ( $ scriptCleaned !== '' ) { return self :: buildHtmlElement ( 'script' , $ attributes , "\n" . $ scriptCleaned . "\n" ) ; } return '' ; }
Build an html script element
43,531
public static function toText ( $ html , bool $ ignoreErrors = false ) : string { return ( string ) ( new \ Html2Text \ Html2Text ( ) ) -> convert ( ( string ) $ html , $ ignoreErrors ) ; }
Convert html to text using html2text
43,532
private function validateIban ( ) : bool { $ value = \ substr ( $ this -> value , 4 ) . \ substr ( $ this -> value , 0 , 4 ) ; $ value = \ str_replace ( [ 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'I' , 'J' , 'K' , 'L' , 'M' , 'N' , 'O' , 'P' , 'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , 'X' , 'Y' , 'Z' ] , [ '10' , '11' , '12' , '13' , '14' , '15' , '16' , '17' , '18' , '19' , '20' , '21' , '22' , '23' , '24' , '25' , '26' , '27' , '28' , '29' , '30' , '31' , '32' , '33' , '34' , '35' ] , $ value ) ; $ tmp = \ intval ( \ substr ( $ value , 0 , 1 ) ) ; $ len = \ strlen ( $ value ) ; for ( $ i = 1 ; $ i < $ len ; ++ $ i ) { $ tmp *= 10 ; $ tmp += \ intval ( \ substr ( $ value , $ i , 1 ) ) ; $ tmp %= 97 ; } $ valid = $ tmp == 1 ? true : false ; if ( ! $ valid ) { $ this -> setError ( self :: VALIDATOR_ERROR_IBAN_INVALID_NUMBER ) ; } return $ valid ; }
Validates IBAN number
43,533
public function connect ( $ pHost , $ pDb , $ pUser = NULL , $ pPass = NULL ) { try { if ( $ pUser !== NULL and $ pPass !== NULL and is_string ( $ pUser ) and is_string ( $ pPass ) ) { $ connection = new PDO ( "mysql:host=$pHost;dbname=$pDb" , $ pUser , $ pPass ) ; } else { $ connection = new PDO ( "mysql:host=$pHost;dbname=$pDb" ) ; } } catch ( PDOException $ e ) { throw new Exception ( "Unable to establish a connection to MySQL: Host '$pHost', DB '$pDb', User '$pUser', Password '$pPass' with message '" . $ e -> getMessage ( ) . "'" ) ; } $ connection -> query ( "SET NAMES 'utf8';" ) ; return $ connection ; }
Establish the database connection .
43,534
public function listCollections ( array $ pWithFields = array ( ) ) { $ tables = array ( ) ; $ prepared = $ this -> getConnection ( ) -> prepare ( 'SHOW TABLES FROM `' . $ this -> _dbName . '`' ) ; if ( $ prepared -> execute ( ) ) { while ( $ row = $ prepared -> fetchObject ( ) ) { $ table = str_replace ( $ this -> getDbPrefix ( ) , '' , current ( $ row ) ) ; foreach ( $ pWithFields as $ field ) { $ preparedJoin = $ this -> getConnection ( ) -> prepare ( 'SHOW COLUMNS FROM `' . current ( $ row ) . '` LIKE "' . $ field . '"' ) ; $ preparedJoin -> execute ( ) ; if ( $ preparedJoin -> execute ( ) and ! $ preparedJoin -> rowCount ( ) ) { continue 2 ; } } $ tables [ ] = $ table ; } } return $ tables ; }
List all the database s collections .
43,535
public static function zeroFill ( $ a , $ b ) { $ z = hexdec ( 80000000 ) ; if ( $ z & $ a ) { $ a = ( $ a >> 1 ) ; $ a &= ( ~ $ z & 0xffffffff ) ; $ a |= 0x40000000 ; $ a = ( $ a >> ( $ b - 1 ) ) ; } else { $ a = ( $ a >> $ b ) ; } return $ a ; }
Fills the zero values
43,536
public static function str2bin ( $ string ) { if ( is_array ( $ string ) || is_object ( $ string ) ) { $ caller = next ( debug_backtrace ( ) ) ; $ error [ 'line' ] = $ caller [ 'line' ] ; $ error [ 'file' ] = strip_tags ( $ caller [ 'file' ] ) ; trigger_error ( "str2bin() expects parameter 1 to be string, " . gettype ( $ string ) . " given in <b>{$error['file']}</b> on line <b>{$error['line']}</b><br />\n" , E_USER_ERROR ) ; return '' ; } if ( strlen ( $ string ) <= 0 ) { return '' ; } $ string = str_split ( $ string , 1 ) ; for ( $ i = 0 , $ n = count ( $ string ) ; $ i < $ n ; ++ $ i ) { $ string [ $ i ] = decbin ( ord ( $ string [ $ i ] ) ) ; $ string [ $ i ] = str_repeat ( "0" , 8 - strlen ( $ string [ $ i ] ) ) . $ string [ $ i ] ; } return implode ( "" , $ string ) ; }
Converting string into binary
43,537
public static function bin2str ( $ string ) { if ( is_array ( $ string ) || is_object ( $ string ) ) { $ caller = next ( debug_backtrace ( ) ) ; $ error [ 'line' ] = $ caller [ 'line' ] ; $ error [ 'file' ] = strip_tags ( $ caller [ 'file' ] ) ; trigger_error ( "bin2str() expects parameter 1 to be string, " . gettype ( $ string ) . " given in <b>{$error['file']}</b> on line <b>{$error['line']}</b><br />\n" , E_USER_ERROR ) ; return '' ; } if ( strlen ( $ string ) <= 0 ) { return '' ; } $ string = str_split ( $ string , 8 ) ; for ( $ i = 0 , $ n = count ( $ string ) ; $ i < $ n ; ++ $ i ) { $ string [ $ i ] = chr ( bindec ( $ string [ $ i ] ) ) ; } return implode ( '' , $ string ) ; }
Converting binary string into normal string
43,538
public static function byte2intSplit ( $ input ) { $ l = strlen ( $ input ) ; if ( $ l <= 0 ) { return 0 ; } elseif ( ( $ l % 4 ) != 0 ) { return false ; } $ result = array ( ) ; for ( $ i = 0 ; $ i < $ l ; $ i += 4 ) { $ int_build = ( ord ( $ input [ $ i ] ) << 24 ) ; $ int_build += ( ord ( $ input [ $ i + 1 ] ) << 16 ) ; $ int_build += ( ord ( $ input [ $ i + 2 ] ) << 8 ) ; $ int_build += ( ord ( $ input [ $ i + 3 ] ) ) ; $ result [ ] = $ int_build ; } return $ result ; }
split a byte - string into integer array values
43,539
public function find ( ) { foreach ( $ this -> getSupportedGateways ( ) as $ gateway ) { $ class = $ this -> helper - getFacadeClassName ( $ gateway ) ; if ( class_exists ( $ class ) ) { $ this -> register ( $ gateway ) ; } } ksort ( $ this -> gateways ) ; return $ this -> all ( ) ; }
Automatically find and register all officially supported gateways
43,540
public function create ( $ className ) { $ facade = $ this -> helper -> getFacadeClassName ( $ className ) ; if ( ! class_exists ( $ facade ) ) { throw new RuntimeException ( "Class '$facade' not found" ) ; } $ className = $ this -> helper -> getSDKClassName ( $ className ) ; return new $ facade ( new $ className ( $ this -> httpClient ) ) ; }
Get the facade for SDK
43,541
public function getOption ( $ name ) { $ method = 'get' . ucfirst ( $ name ) ; if ( method_exists ( $ this , $ method ) && $ method !== __FUNCTION__ ) { return $ this -> $ method ( ) ; } elseif ( isset ( $ this -> options [ $ name ] ) ) { return $ this -> options [ $ name ] ; } }
Get single option
43,542
public function setOption ( $ name , $ value ) { $ method = 'set' . ucfirst ( $ name ) ; if ( method_exists ( $ this , $ method ) && $ method !== __FUNCTION__ ) { return $ this -> $ method ( $ value ) ; } $ this -> options [ $ name ] = $ value ; return $ this ; }
Set single option
43,543
public function transform ( $ umbrellaFile ) { return array ( 'file' => null , 'id' => $ umbrellaFile ? $ umbrellaFile -> id : null , 'text' => $ umbrellaFile ? $ umbrellaFile -> name . ' (' . $ umbrellaFile -> getHumanSize ( ) . ')' : null ) ; }
Transform UmbrellaFile = > array
43,544
public function reverseTransform ( $ array ) { $ id = ArrayUtils :: get ( $ array , 'id' , null ) ; $ umbrellaFile = $ id ? $ this -> em -> getRepository ( UmbrellaFile :: class ) -> find ( $ id ) : null ; $ uploadedFile = ArrayUtils :: get ( $ array , 'file' , null ) ; $ delete = ArrayUtils :: get ( $ array , 'delete' , false ) ; if ( $ umbrellaFile && $ uploadedFile ) { $ this -> em -> remove ( $ umbrellaFile ) ; return $ this -> manager -> createUmbrellaFile ( $ uploadedFile ) ; } if ( $ umbrellaFile && $ uploadedFile === null && $ delete ) { $ this -> em -> remove ( $ umbrellaFile ) ; return null ; } if ( $ umbrellaFile === null && $ uploadedFile ) { return $ this -> manager -> createUmbrellaFile ( $ uploadedFile ) ; } return $ umbrellaFile ; }
Transform array = > UmbrellaFile
43,545
protected function outputSingleResult ( ) { echo $ this -> line ( ) ; echo $ this -> title ( ) ; echo $ this -> line ( ) ; echo $ this -> content ( ) ; echo $ this -> line ( ) ; }
Protected output single result
43,546
protected function outputMultipleResult ( ) { $ this -> return = $ max = max ( $ this -> print ) . ' ' ; echo $ this -> line ( ) ; echo $ this -> title ( ) ; echo $ this -> line ( ) ; foreach ( $ this -> print as $ key => $ ret ) { $ diff = strlen ( $ max ) - strlen ( $ return = $ key . ' | ' . $ ret ) ; $ this -> return = $ return . str_repeat ( ' ' , $ diff ) ; echo $ this -> content ( ) ; echo $ this -> line ( ) ; } }
Protected output multiple result
43,547
public function merge ( ArrayObject $ other , $ recursive = TRUE ) { foreach ( $ other as $ key => $ value ) { if ( $ recursive && $ this -> offsetExists ( $ key ) ) { $ ownvalue = $ this -> offsetGet ( $ key ) ; if ( $ ownvalue instanceof ArrayObject && $ value instanceof ArrayObject ) { $ ownvalue -> merge ( $ value , TRUE ) ; continue ; } } $ this -> offsetSet ( $ key , $ value ) ; } return $ this ; }
Merges values from another Loops \ ArrayObject into this one by keys
43,548
public function toArray ( ) { $ result = iterator_to_array ( $ this ) ; foreach ( $ result as $ key => & $ value ) { if ( $ value instanceof ArrayObject ) { $ value = $ value -> toArray ( ) ; } } return $ result ; }
Returns the keys and values of this object as a standard array
43,549
public static function fromArray ( array $ input ) { $ input = array_map ( function ( $ value ) { return is_array ( $ value ) ? ArrayObject :: fromArray ( $ value ) : $ value ; } , $ input ) ; return new ArrayObject ( $ input ) ; }
Creates an Loops \ ArrayObject from a normal PHP array . Nested arrays will recursively converted .
43,550
public function Gdn_Dispatcher_AppStartup_Handler ( $ Sender ) { header ( 'P3P: CP="CAO PSA OUR"' , TRUE ) ; if ( ! Gdn :: Session ( ) -> IsValid ( ) && $ SSO = Gdn :: Request ( ) -> Get ( 'sso' ) ) { SaveToConfig ( 'Garden.Registration.SendConnectEmail' , FALSE , FALSE ) ; $ UserID = FALSE ; try { $ UserID = Gdn :: UserModel ( ) -> SSO ( $ SSO ) ; } catch ( Exception $ Ex ) { Trace ( $ Ex , TRACE_ERROR ) ; } if ( $ UserID ) { Gdn :: Session ( ) -> Start ( $ UserID , TRUE , TRUE ) ; Gdn :: UserModel ( ) -> FireEvent ( 'AfterSignIn' ) ; } else { Trace ( Gdn :: UserModel ( ) -> Validation -> ResultsText ( ) , TRACE_WARNING ) ; } } }
Set P3P header because IE won t allow cookies thru the iFrame without it .
43,551
public function console ( $ message , $ eolBefor = false ) { $ befor = '' ; if ( $ eolBefor ) { $ befor = PHP_EOL ; } echo $ befor , $ message , PHP_EOL ; return $ this ; }
Show message in cli
43,552
public function run ( ) { if ( $ this -> initialized ) { $ this -> console ( sprintf ( "Start running '%s' method of script '%s'." , $ this -> opts -> action , get_class ( $ this ) ) ) ; $ this -> { $ this -> action } ( ) ; $ this -> console ( sprintf ( "End of running '%s' cli script." , get_class ( $ this ) ) , true ) ; } return $ this ; }
Run cli script
43,553
protected function createTmpFile ( $ content = null ) { $ tmpPath = $ this -> getConfig ( 'tmp' , sys_get_temp_dir ( ) ) ; $ tmpFile = tempnam ( $ tmpPath , 'tmp_WkHtmlToPdf_' ) ; rename ( $ tmpFile , $ tmpFile .= '.html' ) ; if ( ! is_null ( $ content ) ) { file_put_contents ( $ tmpFile , $ content ) ; } $ this -> tmpFiles [ ] = $ tmpFile ; return $ tmpFile ; }
Create a tmp file optionally with given content
43,554
protected function buildArguments ( array $ options = array ( ) ) { $ arguments = array ( ) ; foreach ( $ options as $ key => $ value ) { if ( $ value === false or is_int ( $ key ) ) { continue ; } $ arguments [ ] = "--$key" ; if ( is_array ( $ value ) ) { $ arguments = array_merge ( $ arguments , $ this -> buildArrayArguments ( $ value ) ) ; } elseif ( $ value !== true ) { $ arguments [ ] = $ value ; } } return $ arguments ; }
Build command line options from array
43,555
private function buildArrayArguments ( $ value ) { $ arguments = array ( ) ; foreach ( $ value as $ index => $ option ) { if ( is_string ( $ index ) ) { $ arguments [ ] = $ index ; } $ arguments [ ] = $ option ; } return $ arguments ; }
Build array arguments
43,556
protected function sendHeaders ( $ tmpFile ) { header ( 'Pragma: public' ) ; header ( 'Expires: 0' ) ; header ( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' ) ; header ( 'Content-Type: application/pdf' ) ; header ( 'Content-Transfer-Encoding: binary' ) ; header ( 'Content-Length: ' . filesize ( $ tmpFile ) ) ; }
Send PDF file headers
43,557
public function help ( ) { $ builder = new ProcessBuilder ( array ( '--extended-help' ) ) ; $ builder -> setPrefix ( $ this -> config [ 'bin' ] ) ; $ process = $ builder -> getProcess ( ) ; $ process -> run ( ) ; if ( $ process -> isSuccessful ( ) ) { return $ process -> getOutput ( ) ; } }
Return the extended help of WkHtmlToPdf
43,558
private static function setRoot ( $ url ) { $ segements = explode ( '/' , $ url ) ; $ count = count ( $ segements ) - 2 ; $ path = '' ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ path .= '../' ; } Application :: $ path .= $ path ; return Application :: $ path ; }
Set the app root param .
43,559
private static function treat ( Route $ route , $ params ) { if ( ( $ route -> getMethod ( ) == 'post' && Request :: isPost ( ) ) || ( $ route -> getMethod ( ) == 'get' ) || ( $ route -> getMethod ( ) == 'resource' ) || ( $ route -> getMethod ( ) == 'call' ) ) { return static :: execute ( $ route , $ params ) ; } return false ; }
Treat the request according to it s method .
43,560
private static function execute ( & $ route , $ params ) { array_shift ( $ params ) ; if ( static :: runAppMiddleware ( ) && static :: runRouteMiddleware ( $ route ) ) { static :: prepare ( $ route , $ params ) ; return true ; } }
Execute the route .
43,561
private static function runAppMiddleware ( ) { $ appMiddleware = Filter :: $ middleware ; foreach ( $ appMiddleware as $ middleware ) { $ middleware = instance ( $ middleware ) ; $ middleware -> handle ( new Request ( ) ) ; } return true ; }
Check app middlewares before run the route .
43,562
private static function runRouteMiddleware ( $ route ) { $ routeMiddleware = Filter :: $ routeMiddleware ; if ( ! is_null ( $ route -> getMiddleware ( ) ) ) { foreach ( $ route -> getMiddleware ( ) as $ middleware ) { exception_if ( ! array_has ( $ routeMiddleware , $ middleware ) , RouteMiddlewareNotFoundException :: class , $ middleware ) ; $ middleware = instance ( $ routeMiddleware [ $ middleware ] ) ; $ middleware -> handle ( new Request ( ) ) ; } } return true ; }
Check route middlewares before run the route and check if the requested middleware are realy in filter class .
43,563
private static function prepare ( Route $ route , $ params ) { static :: $ current = $ route ; if ( $ route -> getMethod ( ) == 'resource' ) { if ( $ route -> getTarget ( ) [ 'method' ] == 'update' ) { $ id = $ params [ 0 ] ; $ params [ 0 ] = new Request ( ) ; $ params [ ] = $ id ; } elseif ( $ route -> getTarget ( ) [ 'method' ] == 'insert' ) { $ params [ ] = new Request ( ) ; } self :: treatment ( call_user_func_array ( $ route -> getClosure ( ) , $ params ) ) ; } elseif ( $ route -> getMethod ( ) == 'call' ) { $ target = $ route -> getResource ( ) [ $ route -> name ] -> getTarget ( ) ; self :: treatment ( call_user_func_array ( [ $ target [ 'controller' ] , $ target [ 'method' ] ] , $ params ) ) ; } else { self :: treatment ( call_user_func_array ( $ route -> getClosure ( ) , $ params ) ) ; } }
prepare the route to be executed .
43,564
private static function treatment ( $ result ) { if ( is_string ( $ result ) ) { echo $ result ; } elseif ( $ result instanceof Views ) { View :: show ( $ result ) ; } }
Treat the result of the route closure .
43,565
public static function add ( Route $ route ) { exception_if ( self :: checkDuplicated ( $ route ) , RouteDuplicatedException :: class , $ route ) ; $ routeWithoutSlash = $ route ; $ routeWithSlash = $ route -> getWithSlash ( ) ; self :: $ register [ $ routeWithoutSlash -> getName ( ) ] = $ routeWithoutSlash ; self :: $ register [ $ routeWithSlash -> getName ( ) ] = $ routeWithSlash ; }
Add new route to register .
43,566
public static function edit ( Route $ route ) { $ routeWithoutSlash = $ route ; $ routeWithSlash = $ route -> getWithSlash ( ) ; self :: $ register [ $ routeWithoutSlash -> getName ( ) ] = $ routeWithoutSlash ; self :: $ register [ $ routeWithSlash -> getName ( ) ] = $ routeWithSlash ; }
Update an existant route in register .
43,567
public static function delete ( Route $ route ) { $ routeWithoutSlash = $ route ; $ routeWithSlash = $ route -> getWithSlash ( ) ; if ( check ( self :: $ register [ $ routeWithoutSlash -> getName ( ) ] ) ) { unset ( self :: $ register [ $ routeWithoutSlash -> getName ( ) ] ) ; } if ( check ( self :: $ register [ $ routeWithSlash -> getName ( ) ] ) ) { unset ( self :: $ register [ $ routeWithSlash -> getName ( ) ] ) ; } }
Remove an existant route from register .
43,568
private static function checkDuplicated ( Route $ route ) { foreach ( self :: $ register as $ registeredRoute ) { if ( $ registeredRoute -> getName ( ) == $ route -> getName ( ) ) { return true ; } } return false ; }
Check if route is duplicated .
43,569
public function setCode ( $ code ) { $ code = ( int ) $ code ; if ( ! empty ( $ this -> body ) && ! HttpCode :: isBodyAllowed ( $ code ) ) { throw new LogicException ( 'HTTP response already contains body - response "' . HttpCode :: getName ( $ code ) . '" cannot contain body.' ) ; } $ this -> code = $ code ; $ this -> messageCache = null ; }
Sets HTTP code for response .
43,570
public function setBody ( $ body ) { if ( ! empty ( $ body ) && ! HttpCode :: isBodyAllowed ( $ this -> code ) ) { throw new LogicException ( 'You cannot set non-empty body for currently set code' ) ; } $ this -> body = ( string ) $ body ; $ this -> setHeader ( 'Content-Length' , strlen ( $ this -> body ) ) ; $ this -> messageCache = null ; }
Sets body for response . It also automatically sets correct Content - Length header .
43,571
private function enableSmarty ( ) { if ( $ this -> smarty !== NULL ) { return ; } $ this -> smarty = new Smarty ; $ this -> smarty -> setTemplateDir ( PUBLIC_DIR ) ; $ this -> smarty -> setCompileDir ( PUBLIC_DIR . 'smarty' . DSC . 'compile' ) ; $ this -> smarty -> setCacheDir ( PUBLIC_DIR . 'smarty' . DSC . 'cache' ) ; }
Enables Smarty .
43,572
private function getViewPath ( $ name ) { $ module = $ this -> module_name !== NULL ? ( $ this -> module_name ) . DSC : '' ; return $ this -> getRealPath ( 'views' . DSC . $ module . $ name ) ; }
Returns path to view file .
43,573
public function renderTemplate ( $ name ) { $ data = array_merge ( $ this -> view_data , $ this -> view ) ; $ template = $ this -> getRealPath ( 'template' . DSC . $ name ) ; $ this -> loadView ( $ template , $ data ) ; }
Render given template with all added view .
43,574
public function renderView ( $ name , $ data = array ( ) , $ return = FALSE ) { $ file = $ this -> getViewPath ( $ name ) ; return $ this -> loadView ( $ file , $ data , $ return ) ; }
Render View .
43,575
public function stop ( ) { $ temp [ 'section' ] = $ this -> section ; if ( function_exists ( 'getrusage' ) ) { $ use = getrusage ( ) ; $ user = sprintf ( '%6d.%06d' , $ use [ 'ru_utime.tv_sec' ] , $ use [ 'ru_utime.tv_usec' ] ) ; $ system = sprintf ( '%6d.%06d' , $ use [ 'ru_stime.tv_sec' ] , $ use [ 'ru_stime.tv_usec' ] ) ; $ proctime_end = $ user + $ system ; $ temp [ 'proctime' ] = $ proctime_end - $ this -> proctime ; } else { $ temp [ 'proctime' ] = 'n/a' ; } $ realtime_end = microtime ( true ) ; $ temp [ 'realtime' ] = $ realtime_end - $ this -> realtime ; if ( function_exists ( 'memory_get_usage' ) ) $ temp [ 'mem' ] = memory_get_usage ( ) ; else $ temp [ 'mem' ] = 'n/a' ; $ this -> data [ ] = $ temp ; $ this -> active = false ; }
Stops benchmarking of the actual section .
43,576
public function get ( ) { if ( $ this -> active ) $ this -> stop ( ) ; foreach ( array_keys ( $ this -> data ) as $ key ) { $ row = & $ this -> data [ $ key ] ; $ row [ 'realtime_ms' ] = $ row [ 'realtime' ] * 1000 ; if ( is_numeric ( $ row [ 'proctime' ] ) ) { $ row [ 'proctime_ms' ] = $ row [ 'proctime' ] * 1000 ; } else { $ row [ 'proctime_ms' ] = 'n/a' ; } } $ returner = $ this -> data ; unset ( $ this -> data ) ; return $ returner ; }
Returns an array of all so far benchmarked sections with the measured times .
43,577
public function restoreFormSettings ( ) { if ( count ( $ this -> settingsStack ) < 1 ) { throw new \ UnderflowException ( "No settings on the stack to restore" ) ; } $ settings = array_pop ( $ this -> settingsStack ) ; $ this -> style = $ settings [ 'style' ] ; $ this -> colSize = $ settings [ 'colSize' ] ; $ this -> widgetCol = $ settings [ 'widgetCol' ] ; $ this -> labelCol = $ settings [ 'labelCol' ] ; $ this -> simpleCol = $ settings [ 'simpleCol' ] ; }
Restore the form settings from the stack .
43,578
public function filter ( EventInterface $ event ) { if ( ! $ event instanceof UserEventInterface ) { return null ; } $ channels = $ this -> getChannels ( $ event ) ; if ( empty ( $ channels ) ) { return null ; } $ commonChannels = array_intersect ( $ channels , $ this -> channels ) ; if ( $ commonChannels ) { return true ; } return false ; }
Filters events that are not channel - specific or originate in specified channels .
43,579
protected function getChannels ( UserEventInterface $ event ) { $ command = $ event -> getCommand ( ) ; if ( isset ( $ this -> parameters [ $ command ] ) ) { $ params = $ event -> getParams ( ) ; $ param = $ this -> parameters [ $ command ] ; return preg_grep ( '/^[#&]/' , explode ( ',' , $ params [ $ param ] ) ) ; } return array ( ) ; }
Extracts a list of channel names from a user event .
43,580
public function getMethod ( ) { if ( $ this -> method === null ) { if ( is_null ( $ this -> method_override ) ) { $ this -> method = $ this -> server -> get ( 'request-method' ) ; } else { $ this -> method = $ this -> method_override ; } $ this -> method = strtoupper ( $ this -> method ) ; } return $ this -> method ; }
Get Http Method to lower case .
43,581
public function getBodyParams ( ) { if ( is_array ( $ this -> bodyParams ) ) { return $ this -> bodyParams ; } $ content = $ this -> getBody ( ) -> getContents ( ) ; $ contentType = $ this -> headers -> get ( 'content-type' ) ; if ( $ contentType === 'application/json' ) { $ bodyParams = json_decode ( $ content , true ) ; $ this -> bodyParams = $ bodyParams ? $ bodyParams : [ ] ; } else { parse_str ( $ content , $ this -> bodyParams ) ; } return $ this -> bodyParams ; }
Get all params of input body .
43,582
public function getBodyParam ( $ key , $ default = null ) { $ params = $ this -> getBodyParams ( ) ; if ( array_key_exists ( $ key , $ params ) ) { return $ params [ $ key ] ; } return $ default ; }
Get one param of input body .
43,583
public function withBodyParam ( $ key , $ value ) { $ params = $ this -> getBodyParams ( ) ; $ params [ $ key ] = $ value ; $ this -> bodyParams = $ params ; }
Set a body param .
43,584
public function withBodyParams ( array $ values ) { $ params = $ this -> getBodyParams ( ) ; foreach ( $ values as $ key => $ value ) { $ params [ $ key ] = $ value ; } $ this -> bodyParams = $ params ; }
Set many body param .
43,585
public function getQueryParams ( ) { if ( is_array ( $ this -> queryParams ) ) { return $ this -> queryParams ; } if ( empty ( $ _SERVER [ 'QUERY_STRING' ] ) ) { return [ ] ; } parse_str ( $ _SERVER [ 'QUERY_STRING' ] , $ this -> queryParams ) ; return $ this -> queryParams ; }
Get url params .
43,586
public function withQueryParams ( array $ query ) { $ params = $ this -> getQueryParams ( ) ; foreach ( $ query as $ key => $ value ) { $ params [ $ key ] = $ value ; } $ this -> queryParams = $ params ; }
Set many query param .
43,587
public function withQueryParam ( $ key , $ value ) { $ params = $ this -> getQueryParams ( ) ; $ params [ $ key ] = $ value ; $ this -> queryParams = $ params ; }
Set a query param .
43,588
protected function redefineErrorHandlers ( & $ container ) { $ container [ 'errorHandler' ] = BuilderJsonErrorResponses :: jsonError ( ) ; $ container [ 'phpErrorHandler' ] = BuilderJsonErrorResponses :: jsonPhpError ( ) ; $ container [ 'notFoundHandler' ] = BuilderJsonErrorResponses :: jsonNotFound ( ) ; $ container [ 'notAllowedHandler' ] = BuilderJsonErrorResponses :: jsonNotAllowed ( ) ; }
Redefine error handlers
43,589
protected function redefineResponse ( & $ container ) { $ container [ 'response' ] = function ( Container $ container ) { $ headers = new Headers ( [ 'Content-Type' => 'application/json;charset=utf-8' ] ) ; $ response = new Response ( 200 , $ headers ) ; return $ response -> withProtocolVersion ( $ container -> get ( 'settings' ) [ 'httpVersion' ] ) ; } ; }
Redefine Response object
43,590
public function setAuthenticationUrl ( $ authenticationUrl ) { if ( ! is_string ( $ authenticationUrl ) || strlen ( trim ( $ authenticationUrl ) ) == 0 ) throw new InvalidArgumentException ( __METHOD__ . '; Invalid authentication url, must be a non empty string' ) ; $ this -> authenticationUrl = $ authenticationUrl ; }
Set authentication url of this Authenticator
43,591
public function save ( $ value , & $ response = null ) { $ previousValue = $ this -> dbObject [ $ this -> param ] ; $ this -> dbObject [ $ this -> param ] = $ this -> convert ( $ value ) ; Event :: fire ( 'samson.cms.input.change' , array ( & $ this -> dbObject , $ this -> param , $ previousValue , & $ response ) ) ; $ this -> dbObject -> save ( ) ; }
Save input field value
43,592
public function view ( $ renderer , $ saveHandler = 'save' ) { $ fieldView = $ this -> viewField ( $ renderer ) ; return $ renderer -> view ( $ this -> defaultView ) -> set ( $ this -> cssClass , 'cssClass' ) -> set ( $ this -> value ( ) , 'value' ) -> set ( url_build ( preg_replace ( '/(_\d+)/' , '' , $ renderer -> id ( ) ) , $ saveHandler ) , 'action' ) -> set ( $ this -> entity , 'entity' ) -> set ( $ this -> param , 'param' ) -> set ( $ this -> dbObject -> id , 'objectId' ) -> set ( $ renderer -> id ( ) , 'applicationId' ) -> set ( $ fieldView , 'fieldView' ) -> output ( ) ; }
Function to render class
43,593
public function setProtocol ( string $ name , string $ separator = '://' ) : VfsHandler { $ this -> _protocolName = $ name ?? '' ; $ this -> _protocolSeparator = $ separator ?? '' ; return $ this ; }
Sets the VFS protocol name and separator .
43,594
public function addReplacement ( string $ name , ? string $ value ) : VfsHandler { if ( null === $ value ) { unset ( $ this -> _replacements [ $ name ] ) ; return $ this ; } $ this -> _replacements [ $ name ] = $ value ; return $ this ; }
Add or set a replacement .
43,595
public function addReplacements ( array $ replacements ) : VfsHandler { foreach ( $ replacements as $ name => $ value ) { if ( null === $ value ) { unset ( $ this -> _replacements [ $ name ] ) ; continue ; } $ this -> _replacements [ $ name ] = $ value ; } return $ this ; }
Add or set one or more replacements .
43,596
public function tryParse ( string & $ pathRef , array $ dynamicReplacements = [ ] ) : bool { $ protocol = $ this -> getProtocol ( ) ; if ( '' === $ protocol || ! strStartsWith ( $ pathRef , $ protocol ) ) { return false ; } if ( \ count ( $ dynamicReplacements ) > 0 ) { $ this -> addReplacements ( $ dynamicReplacements ) ; } $ pathRef = $ this -> _rootFolder . DIRECTORY_SEPARATOR . substring ( $ pathRef , \ mb_strlen ( $ protocol ) ) ; $ pathRef = \ preg_replace_callback ( '~\$\{([A-Za-z0-9_.-]+)\}~' , function ( $ matches ) { if ( ! isset ( $ this -> _replacements [ $ matches [ 1 ] ] ) ) { return $ matches [ 0 ] ; } return $ this -> _replacements [ $ matches [ 1 ] ] ; } , $ pathRef ) ; return true ; }
Tries to parse a path using a VFS protocol and replaces the protocol with a path
43,597
private function _calcularImporteNeto ( ) { if ( ! empty ( $ this -> data [ 'Gasto' ] [ 'Impuesto' ] ) && empty ( $ this -> data [ 'Gasto' ] [ 'importe_neto' ] ) ) { if ( ! empty ( $ this -> data [ 'Gasto' ] [ 'Impuesto' ] ) ) { foreach ( $ this -> data [ 'Gasto' ] [ 'Impuesto' ] as $ imp ) { $ this -> data [ 'Gasto' ] [ 'importe_neto' ] += $ imp [ 'neto' ] ; } } } }
Calcula el neto sumando los impuestos y lo setea en el data
43,598
private function _refreshImpuestos ( $ created ) { if ( ! empty ( $ this -> data [ 'Gasto' ] [ 'Impuesto' ] ) ) { if ( ! $ created ) { $ this -> Impuesto -> deleteAll ( array ( 'Impuesto.gasto_id' => $ this -> id ) ) ; } foreach ( $ this -> data [ 'Gasto' ] [ 'Impuesto' ] as $ impId => $ imp ) { if ( ! empty ( $ imp ) ) { if ( ! empty ( $ imp [ 'checked' ] ) && ( ! empty ( $ imp [ 'importe' ] ) || ! empty ( $ imp [ 'neto' ] ) ) ) { $ importe = empty ( $ imp [ 'importe' ] ) ? 0 : $ imp [ 'importe' ] ; $ neto = empty ( $ imp [ 'neto' ] ) ? 0 : $ imp [ 'neto' ] ; $ nuevoImp = array ( 'gasto_id' => $ this -> id , 'tipo_impuesto_id' => $ impId , 'importe' => $ importe , 'neto' => $ neto , ) ; $ this -> Impuesto -> create ( $ nuevoImp ) ; if ( ! $ this -> Impuesto -> save ( ) ) { return false ; } } } } } return true ; }
Ante un cambio en e gasto resetea los valores anteriores
43,599
public function enDeuda ( $ conditions = array ( ) ) { $ dbo = $ this -> getDataSource ( ) ; $ subQuery = $ dbo -> buildStatement ( array ( 'fields' => array ( 'SUM( `Aeg`.`importe` )' ) , 'table' => 'account_egresos_gastos' , 'alias' => 'Aeg' , 'limit' => null , 'offset' => null , 'joins' => array ( ) , 'conditions' => array ( 'Aeg.gasto_id = `Gasto`.`id`' , ) , 'order' => null , 'group' => array ( 'Aeg.gasto_id' ) ) , $ this ) ; $ conditions [ ] = "IFNULL(($subQuery), 0) <> `Gasto`.`importe_total`" ; $ fieldContain [ 'recursive' ] = - 1 ; $ fieldContain [ 'fields' ] = array ( 'Gasto.id' , 'Gasto.id' ) ; $ fieldContain [ 'conditions' ] = $ conditions ; $ ret = parent :: find ( 'list' , $ fieldContain ) ; $ gastos = $ this -> find ( 'all' , array ( 'conditions' => array ( 'Gasto.id' => $ ret ) ) ) ; return $ gastos ; }
Devuelve todos los gastos que adeudan pagos o sea cuyo importe_total no llega a ser cubierto con los pagos realizados