idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
16,500 | public function collectControllerData ( FilterControllerEvent $ event ) { if ( HttpKernelInterface :: SUB_REQUEST === $ event -> getRequestType ( ) ) { return ; } $ controller = $ this -> getClassName ( $ event -> getController ( ) [ 0 ] ) ; $ action = $ event -> getController ( ) [ 1 ] ; $ this -> setController ( $ co... | Collect data from controller . |
16,501 | public function resendAction ( Request $ request , User $ user = null ) { $ currentUser = $ this -> getUser ( ) ; if ( null === $ user ) { $ user = $ currentUser ; if ( ! is_object ( $ user ) || ! $ user instanceof UserInterface ) { throw new AccessDeniedException ( 'This user does not have access to this section.' ) ;... | Resends the account activation link typically sent during registration . |
16,502 | public function getFormByName ( $ name , InputInterface $ input , OutputInterface $ output ) { if ( ! isset ( $ this -> forms [ $ name ] ) ) { throw new \ Exception ( sprintf ( 'Unable to find %s form.' , $ name ) ) ; } return $ this -> createInstance ( $ input , $ output , $ this -> forms [ $ name ] ) ; } | Get form by name . |
16,503 | protected function createInstance ( InputInterface $ input , OutputInterface $ output , Form $ form = null ) { if ( ! isset ( $ form ) ) { $ form = new Form ( ) ; } return $ form -> setInput ( $ input ) -> setOutput ( $ output ) -> setHelperSet ( $ this -> getHelperSet ( ) ) ; } | Create form instance . |
16,504 | public function addTo ( $ address , $ title = '' ) { array_push ( $ this -> toAddresses , $ this -> formatEmailAddress ( $ address , $ title ) ) ; return $ this ; } | Setter method for adding recipients |
16,505 | public function addCC ( $ address , $ title = '' ) { if ( ! isset ( $ this -> headers [ 'CC' ] ) ) { $ this -> headers [ 'CC' ] = array ( ) ; } array_push ( $ this -> headers [ 'CC' ] , $ this -> formatEmailAddress ( $ address , $ title ) ) ; return $ this ; } | Setter method for adding cc recipients |
16,506 | public function addBCC ( $ address , $ title = '' ) { if ( ! isset ( $ this -> headers [ 'BCC' ] ) ) { $ this -> headers [ 'BCC' ] = array ( ) ; } array_push ( $ this -> headers [ 'BCC' ] , $ this -> formatEmailAddress ( $ address , $ title ) ) ; return $ this ; } | Setter method for adding bcc recipients |
16,507 | public function setFrom ( $ address , $ title = '' ) { $ this -> headers [ 'From' ] = $ this -> formatEmailAddress ( $ address , $ title ) ; return $ this ; } | Setter method for setting the single from field |
16,508 | public function setReplyTo ( $ address , $ title = '' ) { $ this -> headers [ 'Reply-To' ] = $ this -> formatEmailAddress ( $ address , $ title ) ; return $ this ; } | Setter method for setting the single reply - to field |
16,509 | public function addAttachment ( $ path , $ type , $ title = '' ) { array_push ( $ this -> attachments , array ( 'path' => $ path , 'type' => $ type , 'title' => $ title , ) ) ; return $ this ; } | Setter method for adding attachments |
16,510 | protected function checkRequiredFields ( ) { if ( empty ( $ this -> toAddresses ) ) { return false ; } if ( empty ( $ this -> subject ) ) { return false ; } if ( empty ( $ this -> plainMessage ) && empty ( $ this -> htmlMessage ) && empty ( $ this -> attachments ) ) { return false ; } return true ; } | Call to check the minimum required fields |
16,511 | protected function buildMessage ( ) { if ( empty ( $ this -> plainMessage ) && empty ( $ this -> htmlMessage ) ) { return '' ; } if ( ! empty ( $ this -> plainMessage ) && empty ( $ this -> htmlMessage ) ) { return $ this -> plainMessage ; } if ( empty ( $ this -> plainMessage ) && ! empty ( $ this -> htmlMessage ) ) {... | Returns a simple email message without attachments |
16,512 | protected function buildMessageWithAttachments ( ) { $ message = array ( ) ; if ( ! empty ( $ this -> plainMessage ) || ! empty ( $ this -> htmlMessage ) ) { array_push ( $ message , "--{$this->boundaryMixed}" ) ; } if ( ! empty ( $ this -> plainMessage ) && ! empty ( $ this -> htmlMessage ) ) { array_push ( $ message ... | Build multi - part message with attachments |
16,513 | protected function buildHeaders ( ) { $ headers = array ( ) ; foreach ( $ this -> headers as $ key => $ value ) { if ( $ key == 'CC' || $ key == 'BCC' ) { $ value = implode ( ', ' , $ value ) ; } array_push ( $ headers , sprintf ( '%s: %s' , $ key , $ value ) ) ; } if ( ! empty ( $ this -> attachments ) ) { array_push ... | Builder for the additional headers needed for multipart emails |
16,514 | protected function buildAttachmentContent ( $ path ) { if ( ! file_exists ( $ path ) ) { $ this -> logger -> error ( "Could not find file {$path} for attaching to Archangel mail." ) ; return '' ; } $ handle = fopen ( $ path , 'r' ) ; $ contents = fread ( $ handle , filesize ( $ path ) ) ; fclose ( $ handle ) ; $ conten... | File reader for attachments |
16,515 | private function registerScript ( ) { ZeroClipboardAsset :: register ( $ this -> getView ( ) ) ; $ clipboardVar = 'client' . preg_replace ( '/[^0-9a-zA-Z_$]/' , '_' , $ this -> id ) ; $ this -> getView ( ) -> registerJs ( 'var ' . $ clipboardVar . ';' , View :: POS_HEAD ) ; $ this -> getView ( ) -> registerJs ( $ clipb... | Register button scripts |
16,516 | public static function convertCsvToJson ( $ csvFilepath , $ jsonFilepath , $ compressed ) { $ lines = file ( $ csvFilepath ) ; $ jsonFile = fopen ( $ jsonFilepath , "w" ) ; $ headers = array ( ) ; if ( $ compressed ) { fwrite ( $ jsonFile , "[" ) ; } else { fwrite ( $ jsonFile , "[" . PHP_EOL ) ; } foreach ( $ lines as... | Converts a CSV file into a JSON file . |
16,517 | public static function convertArrayToCsv ( string $ filepath , array $ rows , bool $ addHeader , string $ delimiter = "," , string $ enclosure = '"' ) { $ fileHandle = fopen ( $ filepath , 'w' ) ; if ( $ fileHandle === FALSE ) { throw new \ Exception ( "Failed to open {$filepath} for writing." ) ; } if ( count ( $ rows... | Create a CSV file from the provided array of data . This is done in a memory efficient manner of writing one line at a time to the file rather then building a massive string and dumping the entire string to the file . |
16,518 | public static function trim ( $ filepath , $ delimiter ) { $ tmpFile = tmpfile ( ) ; $ uploaded_fh = fopen ( $ filepath , "r" ) ; if ( $ uploaded_fh ) { while ( ! feof ( $ uploaded_fh ) ) { $ lineArray = fgetcsv ( $ uploaded_fh , 0 , $ delimiter ) ; if ( ! empty ( $ lineArray ) ) { foreach ( $ lineArray as $ index => $... | Go through the CSV file and trim the values . This saves memory by working line by line rather than reading everything into memory This will replace the existing file s contents so if you need to keep that make a copy first . |
16,519 | public static function removeColumns ( $ filepath , array $ columnIndexes , $ delimiter = "," , $ enclosure = '"' ) { $ tmpFile = tmpfile ( ) ; $ fileHandle = fopen ( $ filepath , "r" ) ; $ lineNumber = 1 ; if ( $ fileHandle ) { while ( ! feof ( $ fileHandle ) ) { $ lineArray = fgetcsv ( $ fileHandle , 0 , $ delimiter ... | Remove columns from a CSV file . |
16,520 | public static function removeRows ( $ filepath , array $ rowIndexes , $ delimiter = "," , $ enclosure = '"' ) { $ tmpFile = tmpfile ( ) ; $ fileHandle = fopen ( $ filepath , "r" ) ; $ lineNumber = 1 ; if ( $ fileHandle ) { while ( ! feof ( $ fileHandle ) ) { $ lineArray = fgetcsv ( $ fileHandle , 0 , $ delimiter , $ en... | Remove rows from a CSV file . |
16,521 | public static function decimalDiff ( $ filepath1 , $ filepath2 , $ delimiter = "," , $ enclosure = '"' ) { $ newFileName = tempnam ( sys_get_temp_dir ( ) , "" ) ; $ newFileHandle = fopen ( $ newFileName , "w" ) ; if ( ! $ newFileHandle ) { throw new \ Exception ( "Cannot create file to store diff in." ) ; } $ fileHandl... | Calculate the mathematical differences between two CSV files . If this comes across string values it will check if they are the same and put the the string in if they are otherwise it will concatenate the two values with a | divider . WARNING - this expects the two files to have the same number of columns and rows . |
16,522 | public static function diffTolerance ( $ filepath1 , $ filepath2 , array $ tolerances , $ compareOtherColumns = true , $ delimiter = "," , $ enclosure = '"' ) { $ hasFailed = false ; $ humanRowNumber = 1 ; $ fileHandle1 = fopen ( $ filepath1 , "r" ) ; $ fileHandle2 = fopen ( $ filepath2 , "r" ) ; if ( ! $ fileHandle1 |... | Perform a diff on two CSV files with a tolerance of values being different by the amount specified . This can be useful in situations with floating point values where the last decimal place may be different . |
16,523 | public function registerHandler ( string $ commandClass , string $ serviceName ) : void { if ( ! Validate :: implementsInterface ( $ commandClass , Command :: class ) ) { $ message = sprintf ( 'Invalid command class: %s' , $ commandClass ) ; throw new DomainException ( $ message ) ; } $ type = Type :: create ( $ comman... | Registers a command handler |
16,524 | protected function registerModule ( $ name , \ OtherCode \ FController \ Modules \ BaseModule $ module ) { $ name = strtolower ( $ name ) ; if ( ! array_key_exists ( $ name , $ this -> modules ) ) { $ module -> connect ( $ this -> services , $ this -> storage , $ this -> messages ) ; $ this -> modules [ $ name ] = $ mo... | Register and instantiate a new module |
16,525 | public function unregisterModule ( $ name ) { if ( array_key_exists ( $ name , $ this -> modules ) ) { unset ( $ this -> modules [ $ name ] ) ; return true ; } return false ; } | Un register a module |
16,526 | protected function registerService ( $ name , $ service ) { $ name = strtolower ( $ name ) ; if ( ! isset ( $ this -> services -> $ name ) ) { $ this -> services -> $ name = $ service ; return true ; } return false ; } | Register and instantiate a new service |
16,527 | public function unregisterService ( $ name ) { $ name = strtolower ( $ name ) ; if ( isset ( $ this -> services -> $ name ) ) { unset ( $ this -> services -> $ name ) ; return true ; } return false ; } | Un register a service |
16,528 | public function run ( $ path , $ data = null ) { $ model = array ( ) ; $ callPath = $ this -> route ( $ path ) ; $ payload = array ( $ this -> modules [ $ callPath -> module ] , $ callPath -> method ) ; if ( isset ( $ data ) ) { foreach ( $ data as $ key => $ argument ) { $ model [ $ key ] = $ argument ; } } return cal... | Perform the main call of the module method |
16,529 | protected function route ( $ path ) { if ( ! preg_match ( '/[a-zA-Z0-9]\.[a-zA-Z0-9]/' , $ path ) ) { throw new \ OtherCode \ FController \ Exceptions \ FControllerException ( "Incorrect module call pattern" , 400 ) ; } $ callPath = explode ( "." , $ path ) ; $ module = strtolower ( $ callPath [ 0 ] ) ; $ method = $ ca... | Check and build the payload call |
16,530 | public function xor ( Set $ set ) : SetInterface { $ set = new \ DS \ Set ( $ set ) ; $ items = $ this -> items -> xor ( $ set ) ; return $ this -> duplicate ( $ items ) ; } | Creates a new set using values in either this set or in another set but not in both . |
16,531 | public function filter ( ? callable $ callback = null ) : SetInterface { $ items = $ callback ? $ this -> items -> filter ( $ callback ) : $ this -> items -> filter ( ) ; return $ this -> duplicate ( $ items ) ; } | Returns a new set containing only the values for which a callback returns true . A boolean test will be used if a callback is not provided . |
16,532 | public function sort ( ? callable $ comparator = null ) : SetInterface { $ comparator ? $ this -> items -> sort ( $ comparator ) : $ this -> items -> sort ( ) ; return $ this ; } | Sorts the set in - place based on an optional callable comparator . |
16,533 | public static function fromFile ( string $ file , string $ package ) { $ html = '' ; if ( file_exists ( $ file ) ) { $ html = file_get_contents ( $ file ) ; $ html = preg_replace ( "/{(.*)template(.*)}/" , "/templates/" . template ( ) . "/" . $ package , $ html ) ; } return $ html ; } | Function for return html from file in template |
16,534 | public function has ( string ... $ path ) : bool { try { $ this -> get ( ... $ path ) ; } catch ( ConfigKeyNotFoundException $ e ) { return false ; } return true ; } | Check whether the config has a specific key . |
16,535 | public function get ( string ... $ path ) { if ( count ( $ path ) === 1 ) { if ( ! $ this -> offsetExists ( $ path [ 0 ] ) ) { throw ConfigKeyNotFoundException :: fromPath ( $ path ) ; } return $ this -> offsetGet ( $ path [ 0 ] ) ; } $ keys = array_reverse ( $ path ) ; $ arr = $ this -> getArrayCopy ( ) ; while ( coun... | Get the value for a specific key . |
16,536 | public function setOption ( $ name , $ value ) { $ this -> validateName ( $ name ) ; $ this -> config [ $ name ] = $ value ; } | Declares a non - transient configuration value |
16,537 | public function attach ( $ id , $ instance ) { if ( $ this -> has ( $ id ) ) { return $ this ; } $ this -> instances [ $ id ] = $ instance ; return $ this ; } | Attach new instance of any class to this container . If already exists does not attach the new instance . |
16,538 | protected static function encodeValue ( $ valueToEncode ) { return openssl_encrypt ( $ valueToEncode , self :: $ encodeMethod , self :: $ privateKey , false , self :: $ initializationVector ) ; } | Encode une valeur |
16,539 | public function get ( string $ key , $ default = null ) { $ keys = explode ( "." , $ key ) ; $ config_file = $ this -> context_directory . DIRECTORY_SEPARATOR . array_shift ( $ keys ) . ".php" ; if ( ! isset ( $ this -> config_content [ $ config_file ] ) ) { if ( ! is_file ( $ config_file ) ) { throw new \ Exception ( ... | get config value or fallback gracefully |
16,540 | public function validateElements ( ) { $ this -> _isValid = true ; $ values = $ this -> getParams ( ) ; $ this -> recValidateElements ( $ this -> _elements , $ values ) ; } | Will run a check on all elements to check if their values are correct . Will also parse the values of the elements to whom parser validators are applied . |
16,541 | public function addDisplayElement ( \ OWeb \ types \ Controller $ element ) { $ this -> _displayElements [ ] = $ element ; if ( $ element instanceof \ Controller \ OWeb \ Helpers \ Form \ Elements \ AbstractElement ) { $ this -> _elements [ ] = $ element ; } } | Add a display element to the Form . If this element is also a Form Element then it will automatically be added to the list of form elements . |
16,542 | public function addElement ( \ Controller \ OWeb \ Helpers \ Form \ Elements \ AbstractElement $ element ) { $ this -> _elements [ ] = $ element ; } | Adds an Form Element to the Form without adding it to the Display List . |
16,543 | public function setAction ( $ actionName ) { $ this -> _action = new Elements \ Hidden ( ) ; $ this -> _action -> setName ( 'action' ) ; $ this -> _action -> setVal ( $ actionName ) ; $ this -> _action -> init ( ) ; } | Set the action of the form . It will generate a hidden element with name action and the desired action name |
16,544 | public function setFormat ( string $ format ) { $ no_render_format = [ 'json' , 'xml' , 'css' , 'js' , 'file' ] ; if ( in_array ( $ format , $ no_render_format ) ) { $ this -> render = false ; } $ this -> format = $ format ; } | Sets the output format |
16,545 | public function ajax ( $ selector = '#content' ) { $ this -> ajax = $ this -> di -> get ( 'core.ajax' ) ; $ cmd = new DomCommand ( $ selector , 'html' , '--empty--' ) ; $ this -> ajax_cmd = $ cmd ; $ content = $ this -> run ( ) ; if ( $ content !== false ) { $ this -> ajax_cmd -> setArgs ( $ content ) ; $ this -> ajax_... | Ajax method to send the result of an action as ajax html command |
16,546 | protected function redirect ( string $ target , array $ params = [ ] , bool $ clear_post = true ) { if ( empty ( $ params ) ) { $ params = $ this -> params ; } $ this -> redirect = [ $ target , $ params , $ clear_post ] ; return $ this ; } | Redirects from one action to another |
16,547 | protected function checkControllerAccess ( $ force = false ) : bool { if ( method_exists ( $ this -> app , 'Access' ) && $ this -> app -> Access ( ) === false ) { return false ; } if ( empty ( $ this -> access ) ) { return true ; } $ perm = [ ] ; if ( array_key_exists ( '*' , $ this -> access ) ) { if ( ! is_array ( $ ... | Checks the controller access of the user |
16,548 | protected function getFormDesigner ( $ id = '' ) { $ fd = new FormDesigner ( $ this -> app -> getName ( true ) ) ; if ( ! $ id ) { $ pieces = [ ] ; $ string = new CamelCase ( $ this -> app -> getName ( ) ) ; $ pieces [ ] = $ string -> uncamelize ( ) ; $ string -> setString ( $ this -> name ) ; $ pieces [ ] = $ string -... | Shorthand method for a FormDesigner instance with auto attached model |
16,549 | protected function setAjaxTarget ( $ target ) { if ( ! empty ( $ this -> ajax_cmd ) ) { $ this -> ajax_cmd -> setSelector ( $ target ) ; } return $ this ; } | Sets the selector name to where the result is ajaxed . |
16,550 | protected function redirectExit ( $ location = '' , $ permanent = false ) { $ this -> render = false ; if ( empty ( $ location ) ) { $ location = BASEURL ; } if ( preg_match ( '~^(ftp|http)[s]?://~' , $ location ) == 0 && substr ( $ location , 0 , 6 ) != 'about:' ) { $ location = BASEURL . $ location ; } $ _SESSION [ '... | Redirect function to make sure the browser doesn t come back and repost the form data |
16,551 | public static function connection ( $ name = 'default' ) { $ databaseConfig = self :: getConnectionConfiguration ( $ name ) ; $ driver = self :: driver ( $ name ) ; $ username = isset ( $ databaseConfig [ 'username' ] ) ? $ databaseConfig [ 'username' ] : null ; $ password = isset ( $ databaseConfig [ 'password' ] ) ? ... | Get connection instance for connection name . |
16,552 | public static function entityManager ( $ name = 'default' ) { if ( isset ( self :: $ entityManagers [ $ name ] ) ) { return self :: $ entityManagers [ $ name ] ; } $ databaseConnection = self :: connection ( $ name ) -> getDbalConnection ( ) ; if ( Configuration :: get ( 'app.env' ) == 'development' ) { $ cache = new A... | Get entity manager for the connection and apps . |
16,553 | public static function driver ( $ name = 'default' , $ driverName = null ) { if ( $ name !== null && $ driverName === null ) { $ databaseConfig = self :: getConnectionConfiguration ( $ name ) ; $ driverName = $ databaseConfig [ 'driver' ] ; } if ( ! isset ( self :: $ drivers [ $ driverName ] ) ) { $ driverClass = new \... | Get driver instance for connection name or driver name . |
16,554 | public static function typeOfValue ( $ value ) { if ( is_null ( $ value ) ) { return self :: TYPE_NULL ; } if ( is_int ( $ value ) ) { return self :: TYPE_INT ; } if ( is_bool ( $ value ) ) { return self :: TYPE_BOOL ; } return self :: TYPE_STR ; } | Get type of value . |
16,555 | protected function setError ( $ field , $ errorType , $ error ) { if ( is_array ( $ error ) ) { if ( ! array_key_exists ( 'status' , $ error ) ) { $ error [ 'status' ] = 400 ; } $ error = $ this -> getFactory ( ) -> newError ( $ error ) ; } return $ this -> setJsonApiError ( $ field , $ errorType , $ error ) ; } | Make it easier to set errors on objects |
16,556 | public function indexAction ( ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ roles = $ em -> getRepository ( 'CoreBundle:Role' ) -> findAll ( ) ; return array ( 'roles' => $ roles , ) ; } | Lists all role entities . |
16,557 | public function addAction ( Request $ request , $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ actor = $ em -> getRepository ( $ this -> get ( 'core_manager' ) -> getActorBundleName ( ) . ':Actor' ) -> findOneById ( $ id ) ; $ trans = $ this -> get ( 'translator' ) ; $ form = $ this -> container -> get... | Add role by ajax |
16,558 | public function newAction ( Request $ request ) { $ role = new Role ( ) ; $ form = $ this -> createForm ( 'CoreBundle\Form\RoleType' , $ role ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ r... | Creates a new role entity . |
16,559 | public function showAction ( Role $ role ) { $ deleteForm = $ this -> createDeleteForm ( $ role ) ; return array ( 'role' => $ role , 'delete_form' => $ deleteForm -> createView ( ) , ) ; } | Finds and displays a role entity . |
16,560 | public function editAction ( Request $ request , Role $ role ) { $ deleteForm = $ this -> createDeleteForm ( $ role ) ; $ editForm = $ this -> createForm ( 'CoreBundle\Form\RoleType' , $ role ) ; $ editForm -> handleRequest ( $ request ) ; if ( $ editForm -> isSubmitted ( ) && $ editForm -> isValid ( ) ) { $ this -> ge... | Displays a form to edit an existing role entity . |
16,561 | public function deleteRoleActorAction ( Request $ request , Role $ role , $ actor ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ actor = $ em -> getRepository ( $ this -> get ( 'core_manager' ) -> getActorBundleName ( ) . ':Actor' ) -> findOneById ( $ actor ) ; $ actor -> getRolesCollection ( ) -> removeEle... | Deletes a role entity . |
16,562 | private function createDeleteForm ( Role $ role ) { return $ this -> createFormBuilder ( ) -> setAction ( $ this -> generateUrl ( 'core_role_delete' , array ( 'id' => $ role -> getId ( ) ) ) ) -> setMethod ( 'DELETE' ) -> getForm ( ) ; } | Creates a form to delete a role entity . |
16,563 | public function populateAppIds ( $ e ) { $ appsArray = $ e -> getParam ( 'apps' ) ; $ appService = $ e -> getTarget ( ) -> getServiceManager ( ) -> get ( 'playgroundfacebook_app_service' ) ; $ apps = $ appService -> getAvailableApps ( ) ; foreach ( $ apps as $ app ) { $ app_label = '' ; if ( $ app -> getAppName ( ) ) {... | This method get the Fb apps and add them as array to PlaygroundGame form so that there is non adherence between modules ... not that satisfied neither |
16,564 | private function validateType ( ) : bool { switch ( $ this -> options [ 'type' ] ) { case 'integer' : $ isValid = \ is_int ( $ this -> value ) ? true : false ; break ; case 'float' : $ isValid = \ is_int ( $ this -> value ) || \ is_float ( $ this -> value ) ? true : false ; break ; default : $ isValid = \ is_int ( $ th... | Checks whether number is of required type . Integers are treated as valid floats . |
16,565 | private function validateGreaterThan ( ) : bool { if ( $ this -> options [ 'min' ] !== null ) { if ( $ this -> options [ 'inclusive' ] === false && $ this -> value <= $ this -> options [ 'min' ] ) { $ this -> setError ( self :: VALIDATOR_ERROR_NUMBER_MUST_BE_HIGHER_THAN_MIN ) ; return false ; } if ( $ this -> value < $... | Checks whether number is greater than specified min number |
16,566 | private function validateLowerThan ( ) : bool { if ( $ this -> options [ 'max' ] !== null ) { if ( $ this -> options [ 'inclusive' ] === false && $ this -> value >= $ this -> options [ 'max' ] ) { $ this -> setError ( self :: VALIDATOR_ERROR_NUMBER_MUST_BE_LOWER_THAN_MAX ) ; return false ; } if ( $ this -> value > $ th... | Checks whether number is lower than specified max number |
16,567 | public function validate ( string ... $ constantNames ) : ResultInterface { $ notDefined = array_filter ( $ constantNames , function ( string $ key ) : bool { return ! defined ( $ key ) ; } ) ; return $ this -> report ( ... $ notDefined ) ; } | Validates constants are defined . |
16,568 | public static function assert ( $ test , $ message , $ code = null ) { if ( ! is_callable ( $ test ) ) { throw new self ( 'Test for assert is not callable' , 500 ) ; } if ( $ test ( ) === true ) { throw new static ( $ message , $ code ) ; } } | Assert a test and throw this exception if it returns true |
16,569 | private function validate ( $ hash , string $ validation_regex ) : void { if ( ! is_string ( $ hash ) || preg_match ( $ validation_regex , $ hash ) === 0 ) { throw new InvalidArgumentException ( 'Expected hash, but got ' . var_export ( $ hash , true ) . '] instead' ) ; } } | Ensures the hash passed in is valid |
16,570 | public function done ( ) { if ( array_diff ( $ this -> registered , $ this -> serviceProvider -> provides ( ) ) ) { throw new ServiceProviderException ( get_class ( $ this -> serviceProvider ) . ' said it would provide: "' . join ( ', ' , $ this -> serviceProvider -> provides ( ) ) . '" but ended up providing "' . join... | Check all the items that were promised were actually registered |
16,571 | public static function assoc_to_keyval ( $ assoc , $ keyField , $ valField ) { if ( ! is_array ( $ assoc ) and ! $ assoc instanceof Iterator ) { throw new InvalidArgumentException ( 'The first parameter must be an array.' ) ; } $ output = [ ] ; foreach ( $ assoc as $ row ) { if ( isset ( $ row [ $ keyField ] ) and isse... | Converts a multi - dimensional associative array into an array of key = > values with the provided field names . |
16,572 | public static function reverse_flatten ( $ array , $ glue = ':' ) { $ return = [ ] ; foreach ( $ array as $ key => $ value ) { if ( stripos ( $ key , $ glue ) !== false ) { $ keys = explode ( $ glue , $ key ) ; $ temp = & $ return ; while ( count ( $ keys ) > 1 ) { $ key = array_shift ( $ keys ) ; $ key = is_numeric ( ... | Reverse a flattened array in its original form . |
16,573 | public static function filter_prefixed ( $ array , $ prefix , $ removePrefix = true ) { $ return = [ ] ; foreach ( $ array as $ key => $ val ) { if ( preg_match ( '/^' . $ prefix . '/' , $ key ) ) { if ( $ removePrefix === true ) { $ key = preg_replace ( '/^' . $ prefix . '/' , '' , $ key ) ; } $ return [ $ key ] = $ v... | Filters an array on prefixed associative keys . |
16,574 | public static function replaceAssoc ( array $ replace , string $ subject ) { return str_replace ( array_keys ( $ replace ) , array_values ( $ replace ) , $ subject ) ; } | Associative analogue str_replace . |
16,575 | public function badge ( $ label , $ colorOrStatus = null , $ toolTipLabel = null ) { switch ( true ) { case ! isset ( $ this -> list [ $ this -> listCount - 1 ] ) : Checkers :: notice ( 'Unable to put badge [' . $ label . '] in list group, no element.' ) ; break ; case $ this -> list [ $ this -> listCount - 1 ] instanc... | Add a badge to current item |
16,576 | public function addItem ( $ label , $ url = null , $ status = null , $ active = false , array $ cssClasses = [ ] , array $ attrs = [ ] ) { return $ this -> addContentItem ( $ label , null , $ url , $ status , $ active , $ cssClasses , $ attrs ) ; } | Simple list item |
16,577 | public function addContentItem ( $ label , $ content , $ url = null , $ status = null , $ active = false , array $ cssClasses = [ ] , array $ attrs = [ ] ) { Checkers :: checkUrl ( $ url ) ; $ status === null || Checkers :: checkStatus ( $ status , null , true ) ; $ url === null || $ this -> ulList = false ; $ this -> ... | List item with content |
16,578 | public function getColumnDDL ( Column $ col ) { $ domain = $ col -> getDomain ( ) ; $ ddl = array ( $ this -> quoteIdentifier ( $ col -> getName ( ) ) ) ; $ sqlType = $ domain -> getSqlType ( ) ; if ( $ this -> hasSize ( $ sqlType ) ) { $ ddl [ ] = $ sqlType . $ domain -> printSize ( ) ; } else { $ ddl [ ] = $ sqlType ... | Builds the DDL SQL for a Column object . |
16,579 | public static function last ( $ name ) { if ( ! $ name ) { $ database = config ( 'database.database' ) ; $ path = root ( ) . 'database/backup' ; $ files = glob ( $ path . '/*.sql' ) ; if ( ! is_null ( $ files ) ) { for ( $ i = count ( $ files ) - 1 ; $ i >= 0 ; $ i -- ) { $ file = $ files [ $ i ] ; $ file = explode ( r... | Get the last database save . |
16,580 | public static function import ( $ name = null ) { $ file = static :: last ( $ name ) ; if ( ! is_null ( $ file ) ) { $ query = ( new Filesystem ( ) ) -> get ( $ file ) ; Database :: exec ( $ query ) ; return true ; } } | Import the last save or custom save . |
16,581 | public static function create ( $ name = null ) { $ name = $ name ? $ name : self :: generateName ( ) ; $ container = new Container ( $ name ) ; $ container -> register ( 'Container' , $ container ) ; self :: $ containers [ $ name ] = $ container ; return $ container ; } | Create container . |
16,582 | public static function get ( $ name = null ) { if ( $ name === null ) { $ name = array_shift ( array_keys ( self :: $ containers ) ) ; } return self :: $ containers [ $ name ] ? self :: $ containers [ $ name ] : null ; } | Get container . |
16,583 | public static function utf8 ( string $ in_p ) { $ value = str_replace ( "<br>" , "\n" , $ in_p ) ; $ value = str_replace ( " " , " " , $ value ) ; $ value = preg_replace ( '/<([\s\S]*?)>/u' , '' , $ value ) ; $ value = preg_replace ( '/<\/([\s\S]*?)>/u' , '' , $ value ) ; return $ value ; } | transform the given string into utf8 format strings |
16,584 | public static function unix_dir ( string $ path ) { $ path = str_replace ( '\\' , '/' , $ path ) ; $ path = preg_replace ( '|(?<=.)/+|' , '/' , $ path ) ; if ( ':' === substr ( $ path , 1 , 1 ) ) { $ path = ucfirst ( $ path ) ; } return $ path ; } | change windows directory into unix directory |
16,585 | public static function windows_dir ( string $ path ) { $ path = str_replace ( '/' , '\\' , $ path ) ; $ path = preg_replace ( '|(?<=.)/+|' , '\\' , $ path ) ; if ( ':' === substr ( $ path , 1 , 1 ) ) { $ path = ucfirst ( $ path ) ; } return $ path ; } | change unix directory into windows directory |
16,586 | public function getCurrentPage ( ) { $ givenRelativeFile = str_replace ( $ this -> environment -> getSourceDirectory ( ) , '' , $ this -> environment -> getSourceFile ( ) ) ; return str_replace ( '.twig' , '' , $ givenRelativeFile ) ; } | will return current parsed page |
16,587 | public function getBasepath ( $ suffix = null ) { $ relativeDirectory = '.' ; $ givenRelativePath = dirname ( $ this -> getCurrentPage ( ) ) ; if ( $ givenRelativePath === '/' ) { $ givenRelativePath = '' ; } $ depth = substr_count ( $ givenRelativePath , '/' ) ; for ( $ i = 0 ; $ i < $ depth ; $ i ++ ) { $ relativeDir... | calculates the relative basepath |
16,588 | public function jsonSerialize ( ) { $ data = new stdClass ( ) ; $ vars = get_object_vars ( $ this ) ; foreach ( $ vars as $ property => $ value ) { if ( $ value === null ) { continue ; } $ data -> { $ property } = $ value ; } return $ data ; } | Get data for JSON serialization . |
16,589 | public function validateProperty ( $ property , $ type , $ value , $ class = __CLASS__ ) { $ aType = gettype ( $ value ) ; if ( $ aType !== $ type ) { throw new JsonModelException ( JsonModelException :: BAD_PROPERTY_TYPE , [ $ property , $ type , $ aType ] ) ; } if ( $ value === null ) { throw new JsonModelException (... | Verify that a property exists and its value is of a specified type . |
16,590 | public function sendJsonLoad ( $ json , $ httpVerb = 'POST' ) { $ communicationId = uniqid ( date ( "Y-m-d-His_" ) ) ; $ this -> logCommunication ( $ json , $ httpVerb , $ communicationId ) ; $ ch = curl_init ( $ this -> apiUrl ) ; curl_setopt_array ( $ ch , array ( CURLOPT_RETURNTRANSFER => true , CURLOPT_POSTFIELDS =... | Send a JSON to the API and returns whatever is to return |
16,591 | public function getJsonArray ( $ json ) { $ response = $ this -> sendJsonLoad ( $ json ) ; $ result = json_decode ( $ response , true ) ; if ( ! $ result && ! is_null ( $ this -> logger ) ) { $ this -> logger -> error ( "json decode failed for " . substr ( $ response , 0 , 100 ) . " that resulted from " . substr ( $ js... | Sends JSON and return array decoded from the received JSON response |
16,592 | public static function instance ( $ id ) { $ class = get_called_class ( ) ; if ( empty ( static :: $ instances [ $ class ] [ $ id ] ) ) { static :: $ instances [ $ class ] [ $ id ] = new static ( $ id ) ; } return static :: $ instances [ $ class ] [ $ id ] ; } | Create and return a cached instance |
16,593 | protected function getNullableDataModel ( $ type , $ shallow , $ object , ... $ properties ) { $ object = $ this -> getNullable ( $ object , ... $ properties ) ; if ( $ object == null ) { return null ; } return $ this -> getDataModel ( $ object , $ type , $ shallow ) ; } | Returns a data object that can be a null |
16,594 | public function notify ( $ message , $ color = Client :: COLOR_YELLOW , $ alert = false , $ format = Client :: FORMAT_TEXT ) { $ query = json_encode ( [ 'message' => $ message , 'color' => $ color , 'notify' => $ alert , 'format' => $ format ] ) ; $ response = $ this -> client -> post ( "/v2/room/{$this->room}/notifica... | Send a notification to the given room . |
16,595 | public static function A2tf ( $ ndp , $ angle , & $ sign , array & $ ihmsf ) { static :: D2tf ( $ ndp , $ angle / D2PI , $ sign , $ ihmsf ) ; return ; } | - - - - - - - - i a u A 2 t f - - - - - - - - |
16,596 | public function get ( $ objectType ) { do { if ( isset ( $ this -> permissionCollections [ $ objectType ] ) ) { return $ this -> permissionCollections [ $ objectType ] ; } $ actualObjectType = $ objectType ; $ objectType = get_parent_class ( $ objectType ) ; } while ( $ objectType !== false ) ; throw new InvalidArgumen... | Return permissions for object type . |
16,597 | public function toMap ( bool $ mutable ) : ArrayMap { if ( $ mutable ) { return new MutableMap ( $ this -> data ) ; } else { return new ImmutableMap ( $ this -> data ) ; } } | Copy the data of this list into a map . Keys are preserved . |
16,598 | public function reduce ( callable $ callback , $ initialValue = null ) { $ data = $ initialValue ; foreach ( $ this -> data as $ value ) { $ data = $ callback ( $ value , $ data ) ; } return $ data ; } | Reduce the list to a single value using a user - provided callback . |
16,599 | public function getElement ( Parser $ parser , ElementInterface $ parent = null ) { $ parser -> getReader ( ) -> open ( $ this -> src ) ; $ parsed = $ parser -> getReader ( ) -> parse ( ) ; return $ parser -> parseElements ( $ parsed [ 'value' ] , $ parent ) ; } | Get an instance of ElementInterface for this reservation |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.