idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
59,500 | protected function checkTransaction ( ) { if ( null !== $ this -> con && ! $ this -> con -> inTransaction ( ) ) { $ this -> con -> beginTransaction ( ) ; } if ( null !== $ this -> con && $ this -> con -> inTransaction ( ) ) { $ this -> items ++ ; } if ( $ this -> items >= Config :: getParam ( 'api.block.limit' , 1000 )... | Checks if the connection has a transaction initialized |
59,501 | public function __toHtml ( $ submitted = false , $ blnSimpleLayout = false ) { if ( ! $ blnSimpleLayout ) { $ this -> setConditionalMeta ( ) ; $ strOutput = str_replace ( "[[metaString]]" , $ this -> __getMetaString ( ) , $ this -> __body ) ; } else { $ this -> setMeta ( "class" , "vf__multifielditem" ) ; $ strOutput =... | Render the string s HTML |
59,502 | public function toJS ( $ intDynamicPosition = 0 ) { $ strOutput = "" ; if ( $ this -> getMeta ( "id" ) ) { $ strId = $ this -> getMeta ( "id" ) ; $ strOutput = "objForm.addElement('{$strId}', '{$strId}');\n" ; $ strOutput .= $ this -> conditionsToJs ( $ intDynamicPosition ) ; } return $ strOutput ; } | Render the string s Javascript |
59,503 | public function generateConfFromDB ( DBUtils $ dbUtils , GuesserInterface $ guesser ) : array { $ this -> conn = $ dbUtils -> getConn ( ) ; $ tables = $ this -> getTablesList ( ) ; if ( empty ( $ tables ) ) { throw new NeuralyzerConfigurationException ( 'No tables to read in that database' ) ; } $ data = [ ] ; foreach ... | Generate the configuration by reading tables + cols |
59,504 | public function save ( array $ data , string $ filename ) { if ( ! is_writeable ( dirname ( $ filename ) ) ) { throw new NeuralyzerConfigurationException ( dirname ( $ filename ) . ' is not writable.' ) ; } file_put_contents ( $ filename , Yaml :: dump ( $ data , 4 ) ) ; } | Save the data to the file as YAML |
59,505 | protected function colIgnored ( string $ table , string $ col ) : bool { if ( $ this -> protectCols === false ) { return false ; } foreach ( $ this -> protectedCols as $ protectedCol ) { if ( preg_match ( "/^$protectedCol\$/" , $ table . '.' . $ col ) ) { return true ; } } return false ; } | Check if that col has to be ignored |
59,506 | protected function getColsList ( string $ table ) : array { $ schema = $ this -> conn -> getSchemaManager ( ) ; $ tableDetails = $ schema -> listTableDetails ( $ table ) ; if ( $ tableDetails -> hasPrimaryKey ( ) === false ) { throw new NeuralyzerConfigurationException ( "Can't work with $table, it has no primary key."... | Get the cols lists from a connection + table |
59,507 | protected function getTablesList ( ) : array { $ schemaManager = $ this -> conn -> getSchemaManager ( ) ; $ tablesInDB = $ schemaManager -> listTables ( ) ; $ tables = [ ] ; foreach ( $ tablesInDB as $ table ) { if ( $ this -> tableIgnored ( $ table -> getName ( ) ) ) { continue ; } $ tables [ ] = $ this -> tablesInCon... | Get the table lists from a connection |
59,508 | protected function guessColsAnonType ( string $ table , array $ cols , GuesserInterface $ guesser ) : array { $ mapping = [ ] ; foreach ( $ cols as $ props ) { $ mapping [ $ props [ 'name' ] ] = $ guesser -> mapCol ( $ table , $ props [ 'name' ] , $ props [ 'type' ] , $ props [ 'len' ] ) ; } return $ mapping ; } | Guess the cols with the guesser |
59,509 | protected function tableIgnored ( string $ table ) : bool { foreach ( $ this -> ignoredTables as $ ignoredTable ) { if ( preg_match ( "/^$ignoredTable\$/" , $ table ) ) { return true ; } } return false ; } | Check if that table has to be ignored |
59,510 | public function countResults ( string $ table ) : int { $ queryBuilder = $ this -> conn -> createQueryBuilder ( ) ; $ rows = $ queryBuilder -> select ( 'COUNT(1)' ) -> from ( $ table ) -> execute ( ) ; return ( int ) $ rows -> fetch ( \ Doctrine \ DBAL \ FetchMode :: NUMERIC ) [ 0 ] ; } | Do a simple count for a table |
59,511 | public function getPrimaryKey ( string $ table ) : string { $ schema = $ this -> conn -> getSchemaManager ( ) ; $ tableDetails = $ schema -> listTableDetails ( $ table ) ; if ( $ tableDetails -> hasPrimaryKey ( ) === false ) { throw new NeuralyzerException ( "Can't find a primary key for '{$table}'" ) ; } return $ tabl... | Identify the primary key for a table |
59,512 | public function getTableCols ( string $ table ) : array { $ schema = $ this -> conn -> getSchemaManager ( ) ; $ tableCols = $ schema -> listTableColumns ( $ table ) ; $ cols = [ ] ; foreach ( $ tableCols as $ col ) { $ cols [ $ col -> getName ( ) ] = [ 'length' => $ col -> getLength ( ) , 'type' => $ col -> getType ( )... | Retrieve columns list for a table with type and length |
59,513 | public function assertTableExists ( string $ table ) : void { if ( $ this -> conn -> getSchemaManager ( ) -> tablesExist ( [ $ table ] ) === false ) { throw new NeuralyzerException ( "Table $table does not exist" ) ; } } | Make sure a table exists |
59,514 | public function getCondition ( string $ field , array $ fieldConf ) : string { $ type = strtolower ( $ fieldConf [ 'type' ] ) ; $ unsigned = $ fieldConf [ 'unsigned' ] ; $ integerCast = $ this -> getIntegerCast ( $ unsigned ) ; $ condition = "(CASE $field WHEN NULL THEN NULL ELSE :$field END)" ; $ typeToCast = [ 'date'... | Build the condition by casting the value if needed |
59,515 | private function getIntegerCast ( bool $ unsigned ) : string { $ driver = $ this -> conn -> getDriver ( ) ; if ( strpos ( $ driver -> getName ( ) , 'mysql' ) ) { return $ unsigned === true ? 'UNSIGNED' : 'SIGNED' ; } return 'INTEGER' ; } | Get the right CAST for an INTEGER |
59,516 | public function first ( ) : ? Post { $ params = array_merge ( $ this -> getParameters ( ) , [ 'limit' => 1 , ] ) ; $ posts = Timber :: get_posts ( $ params , $ this -> postClass ) ; if ( ! is_array ( $ posts ) ) { return null ; } return collect ( $ posts ) -> first ( ) ; } | Get the first Post that matches the current query . If no Post matches then return null . |
59,517 | public function toHtml ( ) { $ this -> setMeta ( "class" , "vf__notes" ) ; $ this -> setConditionalMeta ( ) ; $ strOutput = "<div{$this->__getMetaString()}>\n" ; if ( ! empty ( $ this -> __header ) ) { $ strOutput .= "<h4{$this->__getLabelMetaString()}>$this->__header</h4>\n" ; } if ( ! empty ( $ this -> __body ) ) { i... | Render the Note |
59,518 | public function addComparison ( $ varComparison ) { $ objComparison = null ; if ( is_array ( $ varComparison ) ) { $ varArguments = array_keys ( $ varComparison ) ; if ( isset ( $ varComparison [ "subject" ] ) ) { $ varArguments = array_values ( $ varComparison ) ; } try { $ objReflection = new \ ReflectionClass ( "Com... | Add new comparison to Condition |
59,519 | public function isMet ( $ intDynamicPosition = 0 ) { $ blnResult = false ; switch ( $ this -> __comparisontype ) { default : case ValidForm :: VFORM_MATCH_ANY : foreach ( $ this -> __comparisons as $ objComparison ) { if ( $ objComparison -> check ( $ intDynamicPosition ) ) { $ blnResult = true ; break ; } } break ; ca... | Verify if the condition is met |
59,520 | public function jsonSerialize ( $ intDynamicPosition = null ) { if ( get_class ( $ this -> __subject ) == "ValidFormBuilder\\GroupField" || get_class ( $ this -> __subject ) == "ValidFormBuilder\\Area" ) { $ identifier = $ this -> __subject -> getId ( ) ; } elseif ( get_class ( $ this -> __subject ) == "ValidFormBuilde... | toJson method creates an array representation of the current condition object and all of it s comparions . |
59,521 | public function setLimit ( int $ limit ) { $ this -> limit = $ limit ; if ( $ this -> limit < $ this -> batchSize ) { $ this -> batchSize = $ this -> limit ; } return $ this ; } | Limit of fake generated records for updates and creates |
59,522 | protected function whatToDoWithEntity ( ) : int { $ this -> checkEntityIsInConfig ( ) ; $ entityConfig = $ this -> configEntities [ $ this -> entity ] ; $ actions = 0 ; if ( array_key_exists ( 'cols' , $ entityConfig ) ) { switch ( $ entityConfig [ 'action' ] ) { case 'update' : $ actions |= self :: UPDATE_TABLE ; brea... | Evaluate from the configuration if I have to update or Truncate the table |
59,523 | protected function generateFakeData ( ) : array { $ this -> checkEntityIsInConfig ( ) ; $ colsInConfig = $ this -> configEntities [ $ this -> entity ] [ 'cols' ] ; $ row = [ ] ; foreach ( $ colsInConfig as $ colName => $ colProps ) { $ this -> checkColIsInEntity ( $ colName ) ; $ data = \ call_user_func_array ( [ $ thi... | Generate fake data for an entity and return it as an Array |
59,524 | protected function checkEntityIsInConfig ( ) : void { if ( empty ( $ this -> configEntities ) ) { throw new NeuralyzerConfigurationException ( 'No entities found. Have you loaded a configuration file ?' ) ; } if ( ! array_key_exists ( $ this -> entity , $ this -> configEntities ) ) { throw new NeuralyzerConfigurationEx... | Make sure that entity is defined in the configuration |
59,525 | protected function initFaker ( ) : void { $ language = $ this -> configuration -> getConfigValues ( ) [ 'language' ] ; $ this -> faker = \ Faker \ Factory :: create ( $ language ) ; $ this -> faker -> addProvider ( new \ Edyan \ Neuralyzer \ Faker \ Provider \ Base ( $ this -> faker ) ) ; $ this -> faker -> addProvider... | Init Faker and add additional methods |
59,526 | protected function getFakerObject ( string $ entityName , string $ colName , array $ colProps ) { if ( ! isset ( $ this -> fakers [ $ entityName ] [ $ colName ] ) ) { $ fakerClone = clone $ this -> faker ; $ this -> fakers [ $ entityName ] [ $ colName ] = isset ( $ colProps [ 'unique' ] ) && $ colProps [ 'unique' ] ===... | Get the faker object for a entity column |
59,527 | public function getId ( ) { return ( strpos ( $ this -> __id , "[]" ) !== false ) ? str_replace ( "[]" , "" , $ this -> __id ) : $ this -> __id ; } | Get element s ID |
59,528 | public function getName ( $ blnPlain = false ) { $ strReturn = "" ; if ( $ blnPlain ) { $ strReturn = $ this -> __name ; } else { switch ( $ this -> __type ) { case ValidForm :: VFORM_RADIO_LIST : $ strReturn = $ this -> __name ; break ; case ValidForm :: VFORM_CHECK_LIST : $ strReturn = ( strpos ( $ this -> __name , "... | Get the element s name |
59,529 | public function addField ( $ label , $ value , $ checked = false , $ meta = array ( ) ) { $ name = $ this -> getName ( ) ; $ objField = new GroupField ( $ this -> getRandomId ( $ name ) , $ name , $ this -> __type , $ label , $ value , $ checked , $ meta ) ; $ objField -> setMeta ( "parent" , $ this , true ) ; $ this -... | Add either a radio button or checkbox to the group |
59,530 | public function init ( ) { $ this -> initSession ( ) ; $ this -> session = null === $ _SESSION ? array ( ) : $ _SESSION ; if ( NULL === $ this -> getSessionKey ( '__FLASH_CLEAR__' ) ) { $ this -> clearFlashes ( ) ; $ this -> setSessionKey ( '__FLASH_CLEAR__' , microtime ( TRUE ) ) ; } $ this -> user = array_key_exists ... | Constructor por defecto |
59,531 | public function addButton ( $ label , $ meta = array ( ) ) { $ objButton = new Button ( $ label , $ meta ) ; $ objButton -> setMeta ( "parent" , $ this , true ) ; $ this -> __fields -> addObject ( $ objButton ) ; return $ objButton ; } | Add a button to the navigation object |
59,532 | public function addHtml ( $ html , $ meta = array ( ) ) { $ objString = new StaticText ( $ html , $ meta ) ; $ objString -> setMeta ( "parent" , $ this , true ) ; $ this -> __fields -> addObject ( $ objString ) ; return $ objString ; } | Inject HTML in the navigation element |
59,533 | public function toHtml ( $ submitted = false , $ blnSimpleLayout = false , $ blnLabel = true , $ blnDisplayError = true ) { $ this -> setConditionalMeta ( ) ; $ this -> setMeta ( "class" , "vf__navigation" ) ; $ strReturn = "<div{$this->__getMetaString()}>\n" ; foreach ( $ this -> __fields as $ field ) { $ strReturn .=... | Render the Navigation and it s children |
59,534 | public static function getFlash ( $ key ) { $ var = Security :: getInstance ( ) -> getFlash ( $ key ) ; Security :: getInstance ( ) -> setFlash ( $ key , null ) ; return $ var ; } | Template function that get a flash session var |
59,535 | protected function getToken ( $ requestToken ) { $ prefix = $ this -> options [ 'token_prefix' ] ; if ( null === $ prefix ) { return $ requestToken ; } if ( null === $ requestToken ) { return $ requestToken ; } $ requestToken = trim ( str_replace ( $ prefix , "" , $ requestToken ) ) ; return $ requestToken ; } | Convert token with prefix to normal token |
59,536 | public function cacheSubscribers ( $ num = 1000 , $ page = 1 ) { if ( $ this -> cached != null ) { return $ this -> cached ; } $ this -> cached = $ this -> client -> call ( 'GET' , 'subscribers' , [ 'query' => [ 'per_page' => $ num , 'current_page' => $ page , ] , ] ) ; return $ this -> cached ; } | Cache Subscribers for performance improvement . |
59,537 | public function indexSubscribers ( $ num = 1000 , $ page = 1 ) { if ( $ this -> cache != false ) { return $ this -> cacheSubscribers ( $ num , $ page ) ; } return $ this -> client -> call ( 'GET' , 'subscribers' , [ 'query' => [ 'per_page' => $ num , 'current_page' => $ page , ] , ] ) ; } | Get a defined number of Subscribers . |
59,538 | public function searchSubscribers ( $ search , $ by , $ limit = 1 , $ num = 1000 , $ page = 1 ) { $ subscribers = $ this -> indexSubscribers ( $ num , $ page ) [ 'data' ] ; $ filtered = array_filter ( $ subscribers , function ( $ subscriber ) use ( $ search , $ by ) { if ( array_key_exists ( $ by , $ subscriber ) ) { i... | Search if a defined number of Subscribers exists . |
59,539 | public function getDomain ( ) { $ model = explode ( "\\" , $ this -> getModelNamespace ( ) ) ; return strlen ( $ model [ 0 ] ) || 1 === count ( $ model ) ? $ model [ 0 ] : $ model [ 1 ] ; } | Method that extract the Domain name |
59,540 | protected function hydrateFromRequest ( ) { $ class = new \ ReflectionClass ( $ this -> getModelNamespace ( ) ) ; $ this -> model = $ class -> newInstance ( ) ; $ this -> hydrateModelFromRequest ( $ this -> model , $ this -> data ) ; } | Hydrate fields from request |
59,541 | protected function hydrateBulkRequest ( ) { $ class = new \ ReflectionClass ( $ this -> getModelNamespace ( ) ) ; $ this -> list = [ ] ; foreach ( $ this -> data as $ item ) { if ( is_array ( $ item ) ) { if ( count ( $ this -> list ) < Config :: getParam ( 'api.block.limit' , 1000 ) ) { $ model = $ class -> newInstanc... | Hydrate list elements for bulk insert |
59,542 | protected function saveBulk ( ) { $ tablemap = $ this -> getTableMap ( ) ; foreach ( $ this -> list as & $ model ) { $ con = Propel :: getWriteConnection ( $ tablemap :: DATABASE_NAME ) ; try { $ model -> save ( $ con ) ; $ con -> commit ( ) ; } catch ( \ Exception $ e ) { Logger :: log ( $ e -> getMessage ( ) , LOG_ER... | Save the list of items |
59,543 | protected function hydrateModel ( $ primaryKey ) { try { $ query = $ this -> prepareQuery ( ) ; $ this -> model = $ this -> findPk ( $ query , $ primaryKey ) ; } catch ( \ Exception $ e ) { Logger :: log ( get_class ( $ this ) . ': ' . $ e -> getMessage ( ) , LOG_ERR ) ; } } | Hydrate model from pk |
59,544 | protected function _get ( $ primaryKey ) { $ this -> hydrateModel ( $ primaryKey ) ; return ( $ this -> getModel ( ) instanceof ActiveRecordInterface ) ? $ this -> getModel ( ) : NULL ; } | Extract specific entity |
59,545 | public function json ( $ response , $ status = 200 ) { $ this -> closeTransaction ( $ status ) ; return $ this -> _json ( $ response , $ status ) ; } | Wrapper for json parent method with close transactions and close connections tasks |
59,546 | protected function getModelNamespace ( ) { $ tableMap = $ this -> getModelTableMap ( ) ; return ( null !== $ tableMap ) ? $ tableMap :: getOMClass ( FALSE ) : null ; } | Extract model api namespace |
59,547 | protected function addDefaultListField ( ) { if ( ! in_array ( Api :: API_LIST_NAME_FIELD , array_values ( $ this -> extraColumns ) ) ) { $ tableMap = $ this -> getTableMap ( ) ; $ column = null ; if ( $ tableMap -> hasColumn ( 'NAME' ) ) { $ column = $ tableMap -> getColumn ( 'NAME' ) ; } elseif ( $ tableMap -> hasCol... | Method that add a new field with the Label of the row |
59,548 | public function getOnce ( $ key , $ default = null ) { $ read = $ this -> get ( $ key , $ default ) ; $ this -> delete ( $ key ) ; return $ read ; } | Read a value from the session and unset it this is a form of read once flash memory using the session . |
59,549 | public function addParagraph ( $ strBody , $ strHeader = "" , $ meta = array ( ) ) { $ objParagraph = new Paragraph ( $ strHeader , $ strBody , $ meta ) ; $ objParagraph -> setMeta ( "parent" , $ this , true ) ; $ this -> __fields -> addObject ( $ objParagraph ) ; return $ objParagraph ; } | Add paragraph to Area |
59,550 | public function addMultiField ( $ label = null , $ meta = array ( ) ) { if ( ! array_key_exists ( "dynamic" , $ meta ) ) { $ meta [ "dynamic" ] = $ this -> __dynamic ; } if ( $ this -> __dynamic ) { $ meta [ "dynamic" ] = $ this -> __dynamic ; $ meta [ "dynamicLabel" ] = "" ; } $ objField = new MultiField ( $ label , $... | Add a multifield to the Area |
59,551 | public function hasContent ( $ intCount = 0 ) { $ blnReturn = false ; foreach ( $ this -> __fields as $ objField ) { if ( get_class ( $ objField ) !== "ValidFormBuilder\\Hidden" || get_class ( $ objField ) !== "ValidFormBuilder\\Paragraph" ) { if ( get_class ( $ objField ) == "ValidFormBuilder\\MultiField" ) { $ blnRet... | Verify if any of the child fields in this area has submitted data |
59,552 | protected function getDynamicHtml ( $ intCount = 0 ) { $ strReturn = "" ; if ( $ this -> __dynamic && ! empty ( $ this -> __dynamicLabel ) ) { $ arrFields = array ( ) ; foreach ( $ this -> __fields as $ field ) { switch ( get_class ( $ field ) ) { case "ValidFormBuilder\\MultiField" : foreach ( $ field -> getFields ( )... | Generate extra HTML output to facilitate the dynamic duplication logic |
59,553 | public function toJS ( $ intDynamicPosition = 0 ) { $ strReturn = "" ; foreach ( $ this -> __fields as $ field ) { $ strReturn .= $ field -> toJS ( $ this -> __dynamic ) ; } $ strReturn .= $ this -> conditionsToJs ( $ intDynamicPosition ) ; return $ strReturn ; } | Generate Javascript code . |
59,554 | public function isValid ( ) { $ blnReturn = true ; $ intDynamicCount = $ this -> getDynamicCount ( ) ; for ( $ intCount = 0 ; $ intCount <= $ intDynamicCount ; $ intCount ++ ) { $ blnReturn = $ this -> __validate ( $ intCount ) ; if ( ! $ blnReturn ) { break ; } } return $ blnReturn ; } | Verify if all submitted data of this area and it s children is valid . |
59,555 | public function getDynamicCount ( ) { $ intReturn = 0 ; if ( $ this -> __dynamic ) { $ objCounters = $ this -> getCountersRecursive ( $ this -> getFields ( ) ) ; foreach ( $ objCounters as $ objCounter ) { $ intCounterValue = $ objCounter -> getValidator ( ) -> getValue ( ) ; if ( $ intCounterValue > $ intReturn ) { $ ... | Get the dynamic counter value if this is an dynamic area . |
59,556 | public function getValue ( $ intCount = null ) { $ strName = ( $ intCount > 0 ) ? $ this -> __name . "_" . $ intCount : $ this -> __name ; $ value = ValidForm :: get ( $ strName ) ; return ( ( $ this -> __active && ! empty ( $ value ) ) || ! $ this -> __active ) ? true : false ; } | If this is an active area this will return the value of the checkbox . |
59,557 | private function __validate ( $ intCount = null ) { $ blnReturn = true ; foreach ( $ this -> __fields as $ field ) { if ( ! $ field -> isValid ( $ intCount ) ) { $ blnReturn = false ; break ; } } if ( $ this -> __active && ! $ this -> hasContent ( $ intCount ) ) { $ blnReturn = true ; } return $ blnReturn ; } | Validate this Area and it s children s submitted values |
59,558 | public function regenerateTemplates ( ) { $ this -> generateTemplatesCache ( ) ; $ domains = Cache :: getInstance ( ) -> getDataFromFile ( CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json' , Cache :: JSON , true ) ; $ translations = [ ] ; if ( is_array ( $ domains ) ) { $ translations = $ this -> parsePathTranslations ... | Servicio que regenera todas las plantillas |
59,559 | private function loadDomains ( ) { $ domains = Cache :: getInstance ( ) -> getDataFromFile ( CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json' , Cache :: JSON , true ) ; if ( null !== $ domains ) { foreach ( $ domains as $ domain => $ paths ) { $ this -> addPath ( $ paths [ 'template' ] , preg_replace ( '/(@|\/)/' , ''... | Method that extract all domains for using them with the templates |
59,560 | private function generateTemplatesCache ( ) { $ loader = $ this -> tpl -> getLoader ( ) ; $ availablePaths = $ loader -> getPaths ( ) ; if ( ! empty ( $ availablePaths ) ) { foreach ( $ availablePaths as $ path ) { $ this -> generateTemplate ( $ path ) ; } } } | Method that generate all template caches |
59,561 | public function setLetterType ( $ letterType ) : PostageInfo { if ( ! in_array ( $ letterType , Envelope :: getLetterTypeOptions ( ) ) ) { throw new InvalidArgumentException ( sprintf ( 'Property %s is not supported for %s' , $ letterType , __FUNCTION__ ) ) ; } $ this -> letter [ 'type' ] = $ letterType ; return $ this... | Set the letter type |
59,562 | public static function generateTranslationsFile ( $ absoluteTranslationFileName ) { $ translations = array ( ) ; if ( file_exists ( $ absoluteTranslationFileName ) ) { @ include ( $ absoluteTranslationFileName ) ; } else { Cache :: getInstance ( ) -> storeData ( $ absoluteTranslationFileName , "<?php \$translations = a... | Create translation file if not exists |
59,563 | public static function setLocale ( $ default = null ) { $ locale = self :: extractLocale ( $ default ) ; Logger :: log ( 'Set locale to project [' . $ locale . ']' ) ; putenv ( "LC_ALL=" . $ locale ) ; setlocale ( LC_ALL , $ locale ) ; $ locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale' ; Logger :: log ( 'Set loc... | Method to set the locale |
59,564 | public function map ( array $ verbs , string $ uri , $ callback ) : Route { if ( $ this -> isControllerString ( $ callback ) ) { $ callback = $ this -> normaliseCallbackString ( $ callback ) ; } return parent :: map ( $ verbs , $ uri , $ callback ) ; } | Map a router action to a set of Http verbs and a URI |
59,565 | private function normaliseCallbackString ( string $ callback ) : string { @ list ( $ controller , $ method ) = explode ( '@' , $ callback ) ; if ( class_exists ( $ this -> defaultControllerNamespace . $ controller ) ) { return $ this -> defaultControllerNamespace . $ callback ; } return $ callback ; } | Add the default namespace to the Controller classname if required |
59,566 | public function mapCol ( string $ table , string $ name , string $ type , string $ len = null ) : array { $ colsName = $ this -> getColsNameMapping ( ) ; foreach ( $ colsName as $ colRegex => $ params ) { preg_match ( "/^$colRegex\$/i" , $ table . '.' . $ name , $ matches ) ; if ( ! empty ( $ matches ) ) { return $ par... | Will map cols first by looking for field name then by looking for field type if the first returned nothing |
59,567 | public function addField ( $ label , $ value , $ selected = false , $ meta = array ( ) ) { $ objOption = new SelectOption ( $ label , $ value , $ selected , $ meta ) ; $ objOption -> setMeta ( "parent" , $ this , true ) ; $ this -> __options -> addObject ( $ objOption ) ; return $ objOption ; } | Add option element |
59,568 | public function addGroup ( $ label ) { $ objGroup = new SelectGroup ( $ label ) ; $ objGroup -> setMeta ( "parent" , $ this , true ) ; $ this -> __options -> addObject ( $ objGroup ) ; return $ objGroup ; } | Add optgroup element |
59,569 | public static function compareSlashes ( $ routePattern , $ path ) { $ patternSeparator = count ( explode ( '/' , $ routePattern ) ) ; if ( preg_match ( '/\/$/' , $ routePattern ) ) { $ patternSeparator -- ; } $ routePattern = preg_replace ( '/\/\{.*\}$/' , '' , $ routePattern ) ; $ cleanPatternSeparator = count ( explo... | Function that checks if the long of the patterns match |
59,570 | public static function getDBHelper ( string $ driver ) : string { $ drivers = [ 'pdo_mysql' => MySQL :: class , 'mysql' => MySQL :: class , 'mysql2' => MySQL :: class , 'pdo_pgsql' => PostgreSQL :: class , 'pgsql' => PostgreSQL :: class , 'postgres' => PostgreSQL :: class , 'postgresql' => PostgreSQL :: class , 'pdo_sq... | Find the right local driver from a php extension |
59,571 | public function evaluateExpression ( string $ expression ) { $ expressionLanguage = new ExpressionLanguage ( ) ; return $ expressionLanguage -> evaluate ( $ expression , $ this -> services ) ; } | Evaluate an expression that would be in the most general case an action coming from an Anonymization config |
59,572 | public function evaluateExpressions ( array $ expressions ) : array { $ res = [ ] ; foreach ( $ expressions as $ expression ) { $ res [ ] = $ this -> evaluateExpression ( $ expression ) ; } return $ res ; } | Evaluate a list of expression |
59,573 | private function configure ( ) : void { $ services = array_keys ( $ this -> container -> findTaggedServiceIds ( 'app.service' ) ) ; foreach ( $ services as $ service ) { $ service = $ this -> container -> get ( $ service ) ; $ this -> services [ $ service -> getName ( ) ] = $ service ; } } | Configure that service by registering all services in an array |
59,574 | public function phar ( $ opts = [ 'neuralyzer-version' => 'dev' ] ) { if ( ( int ) ini_get ( 'phar.readonly' ) === 1 ) { throw new \ RuntimeException ( 'You must have phar.readonly = 1 or run' . PHP_EOL . 'php -d phar.readonly=0 vendor/bin/robo (phar|release)' ) ; } $ collection = $ this -> collectionBuilder ( ) ; $ wo... | Build an executable phar |
59,575 | private function anonymizeTable ( string $ table ) : bool { $ total = $ this -> getTotal ( $ table ) ; if ( $ total === 0 ) { $ this -> output -> writeln ( "<info>$table is empty</info>" ) ; return true ; } $ bar = new ProgressBar ( $ this -> output , $ total ) ; $ bar -> setRedrawFrequency ( $ total > 100 ? 100 : 0 ) ... | Anonymize a specific table and display info about the job |
59,576 | private function getTotal ( string $ table ) : int { $ config = $ this -> reader -> getEntityConfig ( $ table ) ; $ limit = ( int ) $ config [ 'limit' ] ; if ( $ config [ 'action' ] === 'insert' ) { return empty ( $ limit ) ? 100 : $ limit ; } $ rows = $ this -> dbUtils -> countResults ( $ table ) ; if ( empty ( $ limi... | Define the total number of records to process for progress bar |
59,577 | protected function setClass ( $ type , & $ meta ) { switch ( $ type ) { case ValidForm :: VFORM_STRING : $ this -> setFieldMeta ( "class" , "vf__string" ) ; $ this -> setFieldMeta ( "class" , "vf__text" ) ; break ; case ValidForm :: VFORM_WORD : $ this -> setFieldMeta ( "class" , "vf__word" ) ; $ this -> setFieldMeta (... | Set type class |
59,578 | public function __toHtml ( $ submitted = false , $ blnSimpleLayout = false , $ blnLabel = true , $ blnDisplayErrors = true , $ intCount = 0 ) { return $ this -> toHtml ( $ submitted , $ blnSimpleLayout , $ blnLabel , $ blnDisplayErrors ) ; } | Generate HTML output for specific dynamic count |
59,579 | public function getRandomId ( $ name ) { if ( strpos ( $ name , "[]" ) !== false ) { $ strReturn = str_replace ( "[]" , "_" . rand ( 100000 , 900000 ) , $ name ) ; } else { $ strReturn = $ name . "_" . rand ( 100000 , 900000 ) ; } return $ strReturn ; } | Generate a random ID for a given field name to prevent having two fields with the same name |
59,580 | public function getDynamicCount ( $ blnParentIsDynamic = false ) { $ intReturn = 0 ; if ( ( $ this -> __dynamic || $ blnParentIsDynamic ) && is_object ( $ this -> __dynamiccounter ) ) { $ intReturn = $ this -> __dynamiccounter -> getValidator ( ) -> getValue ( ) ; } return ( int ) $ intReturn ; } | Get the number of dynamic fields from the dynamic counter field . |
59,581 | protected function getDynamicHtml ( ) { $ strReturn = "" ; if ( $ this -> __dynamic && ! empty ( $ this -> __dynamicLabel ) ) { $ strReturn = "<div class=\"vf__dynamic\"><a href=\"#\" data-target-id=\"{$this->__id}\" " . "data-target-name=\"{$this->__name}\"{$this->__getDynamicLabelMetaString()}>" . $ this -> __dynamic... | Render html element needed for dynamic duplication client - side |
59,582 | protected function sanitize ( $ varValue , $ sanitizations ) { if ( is_array ( $ sanitizations ) ) { foreach ( $ sanitizations as $ value ) { try { if ( is_string ( $ value ) ) { switch ( $ value ) { case "trim" : $ varValue = trim ( $ varValue ) ; break ; case "clear" : $ varValue = "" ; break ; } } elseif ( is_callab... | Sanitize a value according to the order of actions in a sanitize array . |
59,583 | public function setName ( $ strName ) { parent :: setName ( $ strName ) ; if ( is_object ( $ this -> __validator ) ) { $ this -> __validator -> setFieldName ( $ strName ) ; } } | Set a new name for this element |
59,584 | public function getEntityConfig ( string $ entity ) : array { if ( ! array_key_exists ( $ entity , $ this -> configValues [ 'entities' ] ) ) { throw new \ InvalidArgumentException ( "$entity is not set in config" ) ; } return $ this -> configValues [ 'entities' ] [ $ entity ] ; } | Get config values for an entity |
59,585 | private function createModulePath ( $ module , $ mod_path ) { GeneratorHelper :: createDir ( $ mod_path ) ; GeneratorHelper :: createDir ( $ mod_path . $ module ) ; } | Service that creates the root paths for the modules |
59,586 | private function createModulePathTree ( $ module , $ mod_path ) { $ this -> log -> addLog ( "Generamos la estructura" ) ; $ paths = [ "Api" , "Api/base" , "Config" , "Controller" , "Models" , "Public" , "Templates" , "Services" , "Test" , "Doc" , "Locale" , "Locale/" . Config :: getParam ( 'default.locale' , 'es_ES' ) ... | Servicio que genera la estructura base |
59,587 | public static function copyResources ( $ dest , $ force , $ filename_path , $ debug ) { if ( file_exists ( $ filename_path ) ) { $ destfolder = basename ( $ filename_path ) ; if ( ! file_exists ( WEB_DIR . $ dest . DIRECTORY_SEPARATOR . $ destfolder ) || $ debug || $ force ) { if ( is_dir ( $ filename_path ) ) { self :... | Method that copy resources recursively |
59,588 | public static function copyr ( $ src , $ dst ) { $ dir = opendir ( $ src ) ; GeneratorHelper :: createDir ( $ dst ) ; while ( false !== ( $ file = readdir ( $ dir ) ) ) { if ( ( $ file != '.' ) && ( $ file != '..' ) ) { if ( is_dir ( $ src . '/' . $ file ) ) { self :: copyr ( $ src . '/' . $ file , $ dst . '/' . $ file... | Method that copy a resource |
59,589 | public function decode ( $ token ) { try { $ data = JWT :: decode ( $ token , $ this -> secretKey , $ this -> allowed_algs ) ; } catch ( \ UnexpectedValueException $ e ) { throw new \ UnexpectedValueException ( $ e -> getMessage ( ) ) ; } catch ( \ DomainException $ e ) { throw new \ UnexpectedValueException ( $ e -> g... | Token for decoding |
59,590 | public function removeOrder ( $ fieldToRemove ) { $ order = array ( ) ; if ( count ( $ order ) > 0 ) { foreach ( $ this -> fields as $ field => $ direction ) { if ( strtolower ( $ fieldToRemove ) === strtolower ( $ field ) ) { continue ; } $ order [ $ field ] = $ direction ; } } $ this -> fields = $ order ; } | Remove existing order |
59,591 | public static function checkAndLoad ( string $ filename ) : string { $ includePathFilename = \ stream_resolve_include_path ( $ filename ) ; $ localFile = __DIR__ . DIRECTORY_SEPARATOR . $ filename ; $ isReadable = @ \ fopen ( $ includePathFilename , 'r' ) !== false ; if ( ! $ includePathFilename || ! $ isReadable || $ ... | Checks if a PHP source file is readable and loads it . |
59,592 | public function addObject ( $ value , $ blnAddToBeginning = false ) { if ( $ blnAddToBeginning ) { array_unshift ( $ this -> collection , $ value ) ; } else { array_push ( $ this -> collection , $ value ) ; } } | Add object to the collection |
59,593 | public function addObjectAtPosition ( $ value , $ intPosition ) { $ arrTempCollection = array ( ) ; $ intCount = 0 ; if ( $ intPosition >= $ this -> count ( ) ) { $ this -> addObject ( $ value ) ; } else { foreach ( $ this -> collection as $ varObject ) { if ( $ intCount == $ intPosition ) { array_push ( $ arrTempColle... | Add object to the collection at a specified position |
59,594 | public function addObjects ( $ arrObjects , $ blnAddToBeginning = false ) { foreach ( $ arrObjects as $ varObject ) { $ this -> addObject ( $ varObject , $ blnAddToBeginning ) ; } } | Add objects to the collection |
59,595 | public function seek ( $ intPosition ) { if ( is_numeric ( $ intPosition ) && $ intPosition < count ( $ this -> collection ) ) { reset ( $ this -> collection ) ; while ( $ intPosition < key ( $ this -> collection ) ) { next ( $ this -> collection ) ; } } $ this -> isSeek = true ; } | Advance internal pointer to a specific index |
59,596 | public function random ( ) { $ objReturn = null ; $ intIndex = rand ( 0 , ( count ( $ this -> collection ) - 1 ) ) ; if ( isset ( $ this -> collection [ $ intIndex ] ) ) { $ objReturn = $ this -> collection [ $ intIndex ] ; } return $ objReturn ; } | Pick a random child element |
59,597 | public function getFirst ( ) { $ varReturn = null ; if ( count ( $ this -> collection ) > 0 ) { $ varReturn = $ this -> collection [ 0 ] ; } return $ varReturn ; } | Get first element in collection |
59,598 | public function getLast ( $ strType = "" ) { $ varReturn = null ; if ( count ( $ this -> collection ) > 0 ) { if ( ! empty ( $ strType ) ) { $ arrTemp = array_reverse ( $ this -> collection ) ; foreach ( $ arrTemp as $ object ) { if ( get_class ( $ object ) == $ strType ) { $ varReturn = $ object ; break ; } } } else {... | Get last element in collection |
59,599 | public function merge ( $ collection ) { if ( is_object ( $ collection ) && $ collection -> count ( ) > 0 ) { $ this -> collection = array_merge ( $ this -> collection , $ collection -> collection ) ; } } | Merge a collection with this collection . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.