idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
58,700
public function setValues ( array $ values ) { foreach ( $ values as $ name => $ value ) { if ( $ element = $ this -> get ( $ name ) ) { $ element -> setValue ( $ value ) ; } } return $ this ; }
Sets the values form matched elements
58,701
public function validate ( ) { foreach ( $ this as $ element ) { if ( $ element instanceof ValidationAwareInterface || $ element instanceof ContainerInterface ) { $ element -> validate ( ) ; } } return $ this ; }
Runs validation chain in all its elements
58,702
public static function isAbsolute ( $ path ) { list ( $ prefix , $ path , $ absolute ) = self :: _startNormalize ( $ path ) ; return $ absolute ; }
says if the given path is an absolute one or not .
58,703
protected static function _normalizePath ( $ originalPath , $ alwaysArray , $ basePath = '' ) { list ( $ prefix , $ path , $ absolute ) = self :: _startNormalize ( $ originalPath ) ; if ( ! $ absolute && $ basePath ) { list ( $ prefix , $ path , $ absolute ) = self :: _startNormalize ( $ basePath . '/' . $ originalPath...
it returns components of a path after normalization in an array .
58,704
function attainAuthorizationUrl ( iGrantAuthorizeRequest $ grant ) { $ grantParams = $ grant -> assertAuthorizeParams ( ) ; $ response = $ this -> call ( new GetAuthorizeUrl ( $ grantParams ) ) ; if ( $ ex = $ response -> hasException ( ) ) throw $ ex ; return $ response -> expected ( ) ; }
Builds the authorization URL
58,705
function attainAccessToken ( iGrantTokenRequest $ grant ) { $ grantParams = $ grant -> assertTokenParams ( ) ; $ response = $ this -> call ( new Token ( $ grantParams ) ) ; if ( $ ex = $ response -> hasException ( ) ) throw $ ex ; $ r = $ response -> expected ( ) ; if ( ! $ r -> get ( 'access_token' ) ) return $ r ; re...
Requests an access token using a specified grant .
58,706
function withGrant ( $ grantTypeName , array $ overrideOptions = [ ] ) { $ options = [ 'scopes' => $ this -> defaultScopes , 'client_id' => $ this -> clientId , 'client_secret' => $ this -> clientSecret , ] ; if ( ! empty ( $ overrideOptions ) ) $ options = array_merge ( $ options , $ overrideOptions ) ; if ( $ grantTy...
Retrieve Specific Grant Type
58,707
protected function platform ( ) { if ( ! $ this -> platform ) $ this -> platform = new PlatformRest ; $ this -> platform -> setServerUrl ( $ this -> serverUrl ) ; return $ this -> platform ; }
Get Client Platform
58,708
public function render ( $ filename , $ vars = array ( ) ) { $ localTemplate = $ this -> templateDir . '/' . $ filename ; $ themeTemplate = locate_template ( $ filename ) ; if ( ! file_exists ( $ localTemplate ) && ! file_exists ( $ themeTemplate ) ) { throw new NotFoundException ( "View at $localTemplate or $themeTemp...
Renders a template file .
58,709
public function isGranted ( $ resource , $ action = 'view' ) { return $ this -> aclOperator -> isAccessGranted ( $ resource , $ this -> getPermission ( $ action ) ) ; }
Returns whether the user has access granted or not on the given resource for the given action .
58,710
public function generateResourcePath ( $ resource , $ action = 'show' ) { $ configuration = $ this -> registry -> findConfiguration ( $ resource ) ; $ routeName = $ configuration -> getRoute ( $ action ) ; $ route = $ this -> findRoute ( $ routeName ) ; $ requirements = $ route -> getRequirements ( ) ; $ accessor = Pro...
Generates an admin path for the given resource and action .
58,711
public function getPermission ( $ action ) { $ action = strtoupper ( $ action ) ; if ( $ action == 'LIST' ) { return 'VIEW' ; } elseif ( $ action == 'SHOW' ) { return 'VIEW' ; } elseif ( $ action == 'NEW' ) { return 'CREATE' ; } elseif ( $ action == 'EDIT' ) { return 'EDIT' ; } elseif ( $ action == 'REMOVE' ) { return ...
Returns the permission for the given action .
58,712
public function findRoute ( $ routeName ) { $ i18nRouterClass = 'JMS\I18nRoutingBundle\Router\I18nRouterInterface' ; if ( interface_exists ( $ i18nRouterClass ) && $ this -> router instanceof $ i18nRouterClass ) { $ route = $ this -> router -> getOriginalRouteCollection ( ) -> get ( $ routeName ) ; } else { $ route = $...
Finds the route definition .
58,713
protected function setupDefaultMachine ( array $ config ) { $ io_name = isset ( $ config [ 'io_name' ] ) ? ( string ) $ config [ 'io_name' ] : 'item' ; $ no_default_transitions = ! empty ( $ config [ 'crud_machine_no_default_transitions' ] ) ; $ this -> states = array_replace_recursive ( $ no_default_transitions ? arra...
Setup basic CRUD machine .
58,714
protected function recalculateTree ( ) { if ( ! $ this -> nested_sets_enabled ) { throw new \ RuntimeException ( 'Nested sets are disabled for this entity.' ) ; } $ q_table = $ this -> flupdo -> quoteIdent ( $ this -> table ) ; $ cols = $ this -> nested_sets_table_columns ; $ c_order_by = $ this -> nested_sets_order_by...
Recalculate nested - sets tree indices
58,715
private function recalculateSubTree ( $ set , $ left , $ depth , $ q_table , $ c_order_by , $ c_id , $ c_parent_id , $ c_left , $ c_right , $ c_depth ) { foreach ( $ set as $ row ) { $ id = $ row [ 'id' ] ; $ this -> flupdo -> update ( $ q_table ) -> set ( "$c_left = ?" , $ left ) -> set ( "$c_depth = ?" , $ depth ) ->...
Recalculate given subtree .
58,716
protected function _setOptions ( array $ options ) { if ( isset ( $ options [ 'escape' ] ) ) { if ( ! is_callable ( $ options [ 'escape' ] ) ) { throw new InvalidArgumentException ( 'Mustache constructor "escape" option must be callable' ) ; } $ this -> _escape = $ options [ 'escape' ] ; } if ( isset ( $ options [ 'cha...
Helper function for setting options from constructor args .
58,717
public function render ( $ template = null , $ view = null , $ partials = null ) { if ( $ template === null ) $ template = $ this -> _template ; if ( $ partials !== null ) $ this -> _partials = $ partials ; $ otag_orig = $ this -> _otag ; $ ctag_orig = $ this -> _ctag ; $ view [ 'baseUrl' ] = $ this -> server -> siteUr...
Render the given template and view object .
58,718
protected function _renderTemplate ( $ template ) { if ( $ section = $ this -> _findSection ( $ template ) ) { list ( $ before , $ type , $ tag_name , $ content , $ after ) = $ section ; $ rendered_before = $ this -> _renderTags ( $ before ) ; $ rendered_content = '' ; $ val = $ this -> _getVariable ( $ tag_name ) ; sw...
Internal render function used for recursive calls .
58,719
protected function _renderPragmas ( $ template ) { $ this -> _localPragmas = $ this -> _pragmas ; if ( strpos ( $ template , $ this -> _otag . '%' ) === false ) { return $ template ; } $ regEx = $ this -> _preparePragmaRegEx ( $ this -> _otag , $ this -> _ctag ) ; return preg_replace_callback ( $ regEx , array ( $ this...
Initialize pragmas and remove all pragma tags .
58,720
protected function _hasPragma ( $ pragma_name ) { if ( array_key_exists ( $ pragma_name , $ this -> _localPragmas ) && $ this -> _localPragmas [ $ pragma_name ] ) { return true ; } else { return false ; } }
Check whether this Mustache has a specific pragma .
58,721
protected function _getPragmaOptions ( $ pragma_name ) { if ( ! $ this -> _hasPragma ( $ pragma_name ) ) { if ( $ this -> _throwsException ( MustacheException :: UNKNOWN_PRAGMA ) ) { throw new MustacheException ( 'Unknown pragma: ' . $ pragma_name , MustacheException :: UNKNOWN_PRAGMA ) ; } } return ( is_array ( $ this...
Return pragma options if any .
58,722
protected function _renderTags ( $ template ) { if ( strpos ( $ template , $ this -> _otag ) === false ) { return $ template ; } $ first = true ; $ this -> _tagRegEx = $ this -> _prepareTagRegEx ( $ this -> _otag , $ this -> _ctag , true ) ; $ html = '' ; $ matches = array ( ) ; while ( preg_match ( $ this -> _tagRegEx...
Loop through and render individual Mustache tags .
58,723
protected function _renderTag ( $ modifier , $ tag_name , $ leading , $ trailing ) { switch ( $ modifier ) { case '=' : return $ this -> _changeDelimiter ( $ tag_name , $ leading , $ trailing ) ; break ; case '!' : return $ this -> _renderComment ( $ tag_name , $ leading , $ trailing ) ; break ; case '>' : case '<' : r...
Render the named tag given the specified modifier .
58,724
protected function _stringHasR ( $ str ) { foreach ( func_get_args ( ) as $ arg ) { if ( strpos ( $ arg , "\r" ) !== false ) { return true ; } } return false ; }
Returns true if any of its args contains the \ r character .
58,725
protected function _renderEscaped ( $ tag_name , $ leading , $ trailing ) { $ value = $ this -> _renderUnescaped ( $ tag_name , '' , '' ) ; if ( isset ( $ this -> _escape ) ) { $ rendered = call_user_func ( $ this -> _escape , $ value ) ; } else { $ rendered = htmlentities ( $ value , ENT_COMPAT , $ this -> _charset ) ...
Escape and return the requested tag .
58,726
protected function _renderUnescaped ( $ tag_name , $ leading , $ trailing ) { $ val = $ this -> _getVariable ( $ tag_name ) ; if ( $ this -> _varIsCallable ( $ val ) ) { $ val = $ this -> _renderTemplate ( call_user_func ( $ val ) ) ; } return $ leading . $ val . $ trailing ; }
Return the requested tag unescaped .
58,727
protected function _renderPartial ( $ tag_name , $ leading , $ trailing ) { $ partial = $ this -> _getPartial ( $ tag_name ) ; if ( $ leading !== null && $ trailing !== null ) { $ whitespace = trim ( $ leading , "\r\n" ) ; $ partial = preg_replace ( '/(\\r?\\n)(?!$)/s' , "\\1" . $ whitespace , $ partial ) ; } $ view = ...
Render the requested partial .
58,728
protected function _changeDelimiter ( $ tag_name , $ leading , $ trailing ) { list ( $ otag , $ ctag ) = explode ( ' ' , $ tag_name ) ; $ this -> _otag = $ otag ; $ this -> _ctag = $ ctag ; $ this -> _tagRegEx = $ this -> _prepareTagRegEx ( $ this -> _otag , $ this -> _ctag ) ; if ( $ leading !== null && $ trailing !==...
Change the Mustache tag delimiter . This method also replaces this object s current tag RegEx with one using the new delimiters .
58,729
protected function _pushContext ( & $ local_context ) { $ new = array ( ) ; $ new [ ] = & $ local_context ; foreach ( array_keys ( $ this -> _context ) as $ key ) { $ new [ ] = & $ this -> _context [ $ key ] ; } $ this -> _context = $ new ; }
Push a local context onto the stack .
58,730
protected function _popContext ( ) { $ new = array ( ) ; $ keys = array_keys ( $ this -> _context ) ; array_shift ( $ keys ) ; foreach ( $ keys as $ key ) { $ new [ ] = & $ this -> _context [ $ key ] ; } $ this -> _context = $ new ; }
Remove the latest context from the stack .
58,731
protected function _getVariable ( $ tag_name ) { if ( $ tag_name === '.' ) { return $ this -> _context [ 0 ] ; } else if ( strpos ( $ tag_name , '.' ) !== false ) { $ chunks = explode ( '.' , $ tag_name ) ; $ first = array_shift ( $ chunks ) ; $ ret = $ this -> _findVariableInContext ( $ first , $ this -> _context ) ; ...
Get a variable from the context array .
58,732
protected function _getPartial ( $ tag_name ) { if ( ( is_array ( $ this -> _partials ) || $ this -> _partials instanceof ArrayAccess ) && isset ( $ this -> _partials [ $ tag_name ] ) ) { return $ this -> _partials [ $ tag_name ] ; } else { $ partial_file = $ this -> server -> getRelAppPath ( 'views/' . $ tag_name . '....
Retrieve the partial corresponding to the requested tag name .
58,733
public function setName ( $ name ) { $ attrName = $ this -> isMultiple ( ) ? "{$name}[]" : $ name ; $ this -> setAttribute ( 'name' , $ attrName ) ; $ this -> name = $ name ; if ( $ label = $ this -> getLabel ( ) ) { $ this -> getLabel ( ) -> setAttribute ( 'for' , $ this -> generateId ( ) ) ; } return $ this ; }
Sets input name
58,734
public function setLabel ( $ label ) { $ this -> label = $ this -> checkLabel ( $ label ) ; $ class = $ this -> label -> getAttribute ( 'class' ) ; $ this -> label -> setAttribute ( 'for' , $ this -> generateId ( ) ) -> setAttribute ( 'class' , trim ( "control-label {$class}" ) ) ; return $ this ; }
Sets the input label
58,735
protected function generateId ( ) { $ inputId = static :: $ idPrefix . $ this -> getName ( ) ; if ( $ this -> isMultiple ( ) ) { $ inputId = "{$inputId}-{$this->instances}" ; } $ this -> setAttribute ( 'id' , $ inputId ) ; return $ inputId ; }
Generate input id based on provided name
58,736
protected function checkLabel ( $ label ) { if ( $ label instanceof ElementInterface ) { return $ label ; } return $ this -> createLabel ( $ this -> translate ( $ label ) ) ; }
Check provided label
58,737
protected function createLabel ( $ label ) { if ( ! is_string ( $ label ) ) { throw new InvalidArgumentException ( "Provided label is not a string or an ElementInterface " . "interface object." ) ; } $ element = class_exists ( $ label ) ? $ this -> createLabelFromClass ( $ label ) : new Label ( '' , $ label ) ; return ...
Creates label from string
58,738
public function setRequired ( $ required ) { $ this -> required = ( boolean ) $ required ; if ( $ this -> isRequired ( ) ) { $ this -> setAttribute ( 'required' ) ; return $ this ; } if ( $ this -> getAttributes ( ) -> containsKey ( 'required' ) ) { $ this -> getAttributes ( ) -> remove ( 'required' ) ; } return $ this...
Sets the required flag for this input
58,739
public function getInstanceValue ( ) { $ value = $ this -> getValue ( ) ; if ( is_array ( $ value ) && array_key_exists ( $ this -> instances , $ this -> value ) ) { $ value = $ value [ $ this -> instances ] ; } return $ value ; }
If input is multiple get the instance value of it
58,740
protected function updateInstance ( ) { $ this -> instances ++ ; $ id = $ this -> generateId ( ) ; $ this -> setAttribute ( $ id , $ id ) ; if ( $ label = $ this -> getLabel ( ) ) { $ label -> setAttribute ( 'for' , $ id ) ; } return $ this ; }
Updates input id and link it to its label
58,741
public function addRepositoryDefinition ( RepositoryDefinitionInterface $ repositoryDefinition ) { $ slug = $ repositoryDefinition -> getSlug ( ) ; if ( isset ( $ this -> repositoriesBySlug [ $ slug ] ) ) { throw new DomainErrorException ( 'Two repositories has the same "' . $ slug . '" slug!' ) ; } $ this -> repositor...
Add a repository definition to the pool
58,742
function fromRelation ( $ relationship , $ repository , \ Closure $ loadCallback ) { $ class = $ relationship -> getType ( ) ; return $ this -> fromEntity ( $ relationship , $ class , $ repository , $ loadCallback ) ; }
Creates a proxy object for an Everyman relationship .
58,743
function fromEntity ( $ entity , $ class , $ repository , $ callback = null ) { $ meta = $ repository -> fromClass ( $ class ) ; $ proxy = $ this -> createProxy ( $ meta ) ; $ proxy -> __setMeta ( $ meta ) ; $ proxy -> __setEntity ( $ entity ) ; $ proxy -> __setLoadCallback ( $ callback ) ; $ proxy -> __setEntity ( $ e...
Creates a proxy object for a Everyman node or relationship .
58,744
private function createProxy ( GraphElement $ meta ) { $ proxyClass = $ meta -> getProxyClass ( ) ; $ className = $ meta -> getName ( ) ; if ( class_exists ( $ proxyClass , false ) ) { return $ this -> newInstance ( $ proxyClass ) ; } $ targetFile = "{$this->proxyDir}/$proxyClass.php" ; if ( $ this -> debug || ! file_e...
Creates a proxy class for a graph element .
58,745
private function newInstance ( $ proxyClass ) { static $ prototypes = array ( ) ; if ( ! array_key_exists ( $ proxyClass , $ prototypes ) ) { $ prototypes [ $ proxyClass ] = unserialize ( sprintf ( 'O:%d:"%s":0:{}' , strlen ( $ proxyClass ) , $ proxyClass ) ) ; } return clone $ prototypes [ $ proxyClass ] ; }
Create a new instance of a proxy class object .
58,746
private function methodProxy ( $ method , $ meta ) { $ property = $ meta -> findProperty ( $ method -> getName ( ) ) ; if ( ! $ property ) { return ; } if ( $ property -> isProperty ( ) && ! $ property -> isStart ( ) && ! $ property -> isEnd ( ) ) { return ; } $ parts = array ( ) ; $ arguments = array ( ) ; foreach ( $...
Creates proxy methods from the reflection method handle and meta information .
58,747
public static function remove ( $ path ) { if ( is_dir ( $ path ) ) { if ( false === ( $ dir = opendir ( $ path ) ) ) { throw FileException :: removeFailed ( $ path ) ; } while ( false !== ( $ item = readdir ( $ dir ) ) ) { if ( ( '.' === $ item ) || ( '..' === $ item ) ) { continue ; } self :: remove ( $ path . DIRECT...
Recursively removes a path from the file system .
58,748
protected function serialize ( $ value ) { if ( ! is_array ( $ value ) ) { return $ value ; } return Serialize :: serialize ( $ value , $ this -> serializer ) ; }
Serialize value .
58,749
protected function microtime ( $ microtime = null ) { list ( $ usec , $ sec ) = explode ( " " , $ microtime ? : microtime ( ) ) ; return ( float ) $ usec + ( float ) $ sec ; }
Returns a microtime .
58,750
public function binaryFile ( $ file , $ status = 200 , array $ headers = [ ] , $ public = true , $ contentDisposition = null , $ autoEtag = false , $ autoLastModified = true ) { return new BinaryFileResponse ( $ file , $ status , $ headers , $ public , $ contentDisposition , $ autoEtag , $ autoLastModified ) ; }
Create a new BinaryFileResponse
58,751
public function fileDownload ( $ file ) { $ response = new SymfonyResponse ( ) ; $ response -> headers -> set ( 'Content-Disposition' , $ response -> headers -> makeDisposition ( ResponseHeaderBag :: DISPOSITION_ATTACHMENT , $ file ) ) ; return $ response ; }
Create a new file download response
58,752
private function generateMeta ( ) : void { $ generator = new Meta \ Generator ( ) ; $ generator -> register ( $ this -> generateMetaDataForRouter ( Broker :: getInstance ( ) , 'getRouter' ) ) ; $ generator -> register ( $ this -> generateMetaDataForRouter ( Broker :: getInstance ( ) -> getRouter ( Locator \ ByClassName...
Generates file with meta
58,753
public function setRequest ( $ request , $ waitForResult = true ) { $ this -> previousRequest = $ this -> request ; $ this -> request = $ request ; $ this -> waitForResult = $ waitForResult ; $ this -> bucket -> refresh ( $ this ) ; return $ this ; }
Sets the request the client is interested in .
58,754
public function seleccionarBd ( $ basedatos ) { if ( $ this -> pdo -> exec ( 'USE ' . $ basedatos ) === false ) { if ( $ this -> arrojarExcepciones ) { throw new \ RuntimeException ( 'No se pudo seleccionar base de datos.' ) ; } return false ; } return true ; }
Selecciona la base de datos interna .
58,755
public function prepararValor ( $ valor , $ tipo = 'txt' , $ permiteVacio = false ) { if ( is_array ( $ valor ) ) { if ( empty ( $ valor ) ) { return 'NULL' ; } foreach ( $ valor as $ llave => $ v ) { $ valor [ $ llave ] = $ this -> prepararValor ( $ v , $ tipo ) ; } return $ valor ; } if ( $ tipo == 'bol' || $ tipo ==...
Prepara valor segun tipo especificado .
58,756
public function obtenerPrimero ( $ clase = null , array $ claseArgs = [ ] ) { $ resultado = $ this -> obtener ( null , null , $ clase , $ claseArgs ) ; if ( $ resultado !== false ) { return array_shift ( $ resultado ) ; } return false ; }
Devuelve el primer registro generado por la consulta de la sentencia interna .
58,757
public function ejecutar ( ) { if ( empty ( $ this -> sentencia ) ) { if ( $ this -> arrojarExcepciones ) { throw new \ InvalidArgumentException ( 'La sentencia a ejecutar se encuentra vacia.' ) ; } return false ; } $ resultado = $ this -> pdo -> exec ( $ this -> sentencia ) ; if ( $ resultado === false ) { if ( $ this...
Ejecuta la sentencia interna .
58,758
public function preparar ( ) { if ( empty ( $ this -> sentencia ) ) { if ( $ this -> arrojarExcepciones ) { throw new \ InvalidArgumentException ( 'La sentencia a preparar se encuentra vacia.' ) ; } } return $ this -> pdo -> prepare ( $ this -> sentencia ) ; }
Prepara la sentencia interna para su uso exterior .
58,759
public function seleccionar ( $ campos , $ tabla ) { if ( is_array ( $ campos ) ) { $ this -> sentencia = 'SELECT ' . implode ( ', ' , $ campos ) ; } else { $ this -> sentencia = 'SELECT ' . $ campos ; } $ this -> sentencia .= ' FROM ' . $ tabla ; return $ this ; }
Inicia la sentencia interna con SELECT .
58,760
public function donde ( array $ params = null ) { if ( $ params ) { $ terminos_sql = [ ] ; foreach ( $ params as $ llave => $ valor ) { $ llave = trim ( $ llave ) ; if ( false === ( $ temp = strpos ( $ llave , ' ' ) ) ) { $ restante = $ llave ; } else { $ restante = substr ( $ llave , 0 , $ temp ) ; $ operador = substr...
Prepara los campos que filtran la sentencia interna .
58,761
public function limitar ( $ pos , $ limite = null ) { if ( $ limite ) { $ this -> sentencia .= ' LIMIT ' . $ pos . ',' . $ limite ; } else { $ this -> sentencia .= ' LIMIT ' . $ pos ; } return $ this ; }
Implementa LIMIT a la sentencia interna .
58,762
public function actualizar ( $ tabla , array $ params ) { $ terminos_sql = [ ] ; foreach ( $ params as $ llave => $ valor ) { $ temp = explode ( '|' , $ llave ) ; $ campo = $ temp [ 0 ] ; if ( isset ( $ temp [ 1 ] ) ) { $ tipo = $ temp [ 1 ] ; } else { $ tipo = 'auto' ; } $ terminos_sql [ ] = $ campo . ' = ' . $ this -...
Inicia la sentencia interna con UPDATE .
58,763
public function insertar ( $ tabla , array $ params ) { $ columnas = [ ] ; $ valores = [ ] ; foreach ( $ params as $ llave => $ valor ) { $ temp = explode ( '|' , $ llave ) ; $ campo = $ temp [ 0 ] ; if ( isset ( $ temp [ 1 ] ) ) { $ tipo = $ temp [ 1 ] ; } else { $ tipo = 'auto' ; } $ columnas [ ] = $ campo ; $ valore...
Inicia la sentencia interna con INSERT .
58,764
public function get ( $ url , $ data ) { curl_setopt ( $ this -> _ch , CURLOPT_CUSTOMREQUEST , 'GET' ) ; curl_setopt ( $ this -> _ch , CURLOPT_URL , sprintf ( "%s?%s" , $ url , http_build_query ( $ data , '' , '&' , PHP_QUERY_RFC3986 ) ) ) ; curl_setopt ( $ this -> _ch , CURLOPT_HTTPHEADER , array ( "Accept:application...
Perform an HTTP GET
58,765
protected function _initialize ( ) { $ this -> _ch = curl_init ( ) ; $ this -> _last_info = FALSE ; curl_setopt ( $ this -> _ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ this -> _ch , CURLOPT_SSL_VERIFYPEER , false ) ; curl_setopt ( $ this -> _ch , CURLOPT_TIMEOUT , 60 ) ; curl_setopt ( $ this -> _ch , CURLOP...
Initialize the curl resource and options
58,766
protected function _exec ( ) { $ response = curl_exec ( $ this -> _ch ) ; $ this -> _last_info = curl_getinfo ( $ this -> _ch ) ; $ error = curl_error ( $ this -> _ch ) ; if ( $ error ) { throw new \ Exception ( $ error ) ; } return $ response ; }
Execute a curl request . Maintain the info from the request in a variable
58,767
public function get ( AbstractModel $ model ) { if ( ! $ this -> repo -> isModel ( $ model ) ) { throw new InvalidArgumentException ( sprintf ( 'Model must be %s, was %s' , $ this -> repo -> getModelClass ( ) , get_class ( $ model ) ) ) ; } if ( $ this -> map -> contains ( $ model ) ) { return $ this -> map [ $ model ]...
Get Links object associated with this model . If there is none an empty Links object is created .
58,768
protected function getKeysForSource ( int $ sourceId ) : \ Traversable { $ row = $ this -> getRow ( $ sourceId ) ; foreach ( $ this -> extractors as $ extractor ) { switch ( true ) { case $ extractor instanceof MultiStringExtractorInterface : foreach ( $ extractor -> keys ( $ row ) as $ key ) { yield $ extractor -> nam...
Get the keys for the source id .
58,769
protected function createValueReader ( int $ sourceId , int $ targetId , ExtractorInterface $ extractor , string $ trail ) : TranslationValueInterface { return new TranslationValue ( $ this , $ sourceId , $ targetId , $ extractor , $ trail ) ; }
Create a value reader instance .
58,770
protected function createValueWriter ( int $ sourceId , int $ targetId , ExtractorInterface $ extractor , string $ trail ) : WritableTranslationValueInterface { return new WritableTranslationValue ( $ this , $ sourceId , $ targetId , $ extractor , $ trail ) ; }
Create a value writer instance .
58,771
public function addPath ( $ db_filename = null , $ db_directory = null , $ file = null ) { if ( ! empty ( $ db_filename ) && ! in_array ( $ db_filename , $ this -> _paths [ 'language_strings_db_filename' ] ) ) { $ this -> _paths [ 'language_strings_db_filename' ] [ ] = $ db_filename ; } if ( ! empty ( $ db_directory ) ...
Add a path to the registry
58,772
public function getParsedOption ( $ name , $ lang = null , $ default = null ) { $ val = $ this -> getOption ( $ name , $ default ) ; if ( false !== strpos ( $ val , '%s' ) ) { if ( is_null ( $ lang ) ) { $ i18n = I18n :: getInstance ( ) ; $ lang = $ i18n -> getLanguage ( ) ; } if ( is_array ( $ lang ) ) { array_unshift...
Parse an option value replacing %s by the actual language code
58,773
public function buildLanguageFileName ( $ lang , $ db_filename = null ) { if ( empty ( $ db_filename ) ) { $ db_filename = $ this -> getParsedOption ( 'language_strings_db_filename' ) ; } $ filename = pathinfo ( $ db_filename , PATHINFO_FILENAME ) ; return $ this -> getParsedOption ( 'language_filename' , array ( $ fil...
Build the file name for the language database
58,774
public function agregarCabecera ( $ nombre , $ valor ) { if ( isset ( $ this -> cabeceras [ $ nombre ] ) ) { $ this -> cabeceras [ $ nombre ] [ ] = $ valor ; } else { $ this -> cabeceras [ $ nombre ] = [ $ valor ] ; } }
Agrega una cabecera a la respuesta .
58,775
public function agregarGalleta ( $ nombre , $ valor , $ expira = 0 , $ camino = '/' , $ dominio = null , $ seguro = false , $ soloHttp = false ) { $ extras = '' ; if ( $ expira ) { $ extras .= ';Expires=' . gmdate ( 'D, d M Y H:i:s \G\M\T' , $ expira ) ; } if ( $ camino ) { $ extras .= ';Path=' . $ camino ; } if ( $ do...
Agrega una galleta a la respuesta .
58,776
public function enviarArchivo ( $ nombre ) { $ this -> definirCabecera ( 'Pragma' , 'public' ) ; $ this -> definirCabecera ( 'Expires' , '0' ) ; $ this -> definirCabecera ( 'Cache-Control' , 'must-revalidate, post-check=0, pre-check=0' ) ; $ this -> definirCabecera ( 'Content-Length' , ( function_exists ( 'mb_strlen' )...
Envia un archivo al navegador .
58,777
public function redirigir ( $ url , $ estadoHttp = 302 ) { $ this -> definirCabecera ( 'Location' , $ url ) ; $ this -> definirEstadoHttp ( $ estadoHttp ) ; $ this -> definirContenido ( null ) ; return $ this ; }
Redirige el navegador a la URL especificada .
58,778
public function run ( SymfonyRequest $ request = null ) { if ( defined ( 'WELOQUENT_TEST_ENV' ) && WELOQUENT_TEST_ENV ) { return ; } $ request = $ request ? : $ this [ 'request' ] ; $ response = with ( $ stack = $ this -> getStackedClient ( ) ) -> handle ( $ request ) ; if ( ! is_admin ( ) ) { $ response -> sendHeaders...
Run the application and save headers . The response is up to WordPress
58,779
public function getLeaderboardTypes ( ) { $ leaderboardTypesArray = array ( ) ; $ leaderboardTypesService = $ this -> getServiceManager ( ) -> get ( 'playgroundreward_leaderboardtype_service' ) ; $ leaderboardTypes = $ leaderboardTypesService -> getLeaderboardTypeMapper ( ) -> findAll ( ) ; foreach ( $ leaderboardTypes...
retrieve all leaderboard type for associate to storyMapping
58,780
public static function rules ( $ type , $ config = array ( ) ) { $ var = '_' . $ type ; if ( ! isset ( static :: $ { $ var } ) ) { return null ; } if ( empty ( $ config ) ) { return static :: $ { $ var } ; } switch ( $ type ) { case 'transliteration' : $ _config = array ( ) ; foreach ( $ config as $ key => $ val ) { if...
Gets or adds inflection and transliteration rules .
58,781
public static function pluralize ( $ word ) { if ( isset ( static :: $ _pluralized [ $ word ] ) ) { return static :: $ _pluralized [ $ word ] ; } extract ( static :: $ _plural ) ; if ( ! isset ( $ regexUninflected ) || ! isset ( $ regexIrregular ) ) { $ regexUninflected = static :: _enclose ( join ( '|' , $ uninflected...
Changes the form of a word from singular to plural .
58,782
public static function limitExact ( $ value , $ limit = 100 , $ end = '...' ) { if ( static :: length ( $ value ) <= $ limit ) { return $ value ; } $ limit -= static :: length ( $ end ) ; return static :: limit ( $ value , $ limit , $ end ) ; }
Limit the number of chracters in a string including custom ending
58,783
public function getProgress ( $ total = null ) { if ( ! $ this -> progress || $ this -> progress -> getMaxSteps ( ) === $ this -> progress -> getProgress ( ) ) { $ this -> progress = new ProgressBar ( $ this -> output , $ total ) ; } return $ this -> progress ; }
Get progress bar instance
58,784
public function flush ( ) { if ( ! $ this -> progress ) { $ this -> log ( '' ) ; foreach ( $ this -> logs as $ message ) { $ this -> log ( $ message ) ; } $ this -> logs = [ ] ; } }
Flush message queue
58,785
public static function register ( $ implementation ) { $ object = new $ implementation ( ) ; if ( ! ( $ object instanceof \ Phramework \ Authentication \ IAuthentication ) ) { throw new \ Exception ( 'Class is not implementing \Phramework\Authentication\IAuthentication' ) ; } self :: $ implementations [ ] = $ object ; ...
Register an authentication implementation . Implementation must implement \ Phramework \ Authentication \ IAuthentication interface
58,786
public static function check ( $ params , $ method , $ headers ) { if ( count ( self :: $ implementations ) !== 0 && ! self :: $ userGetByEmailMethod ) { throw new \ Phramework \ Exceptions \ ServerException ( 'getUserByEmail method is not set' ) ; } foreach ( self :: $ implementations as $ implementation ) { if ( $ im...
Check user s authentication This method iterates through all available authentication implementations tests in priorioty order which of them might be provided and executes
58,787
public function filter ( \ Closure $ predicate ) { $ filter = array ( ) ; $ filter [ 0 ] = function ( FixedFDirectory $ obj ) use ( $ predicate , & $ filter ) { return $ obj -> filter ( $ predicate ) -> map ( function ( FSObject $ obj ) use ( $ predicate , & $ filter ) { if ( $ obj -> isFile ( ) ) { return $ obj ; } re...
Get a recursor that folds all files in this recursor that match the provided predicate and the objects below that match the predicate as well .
58,788
public function cata ( \ Closure $ trans ) { return $ trans ( $ this -> directory -> unfix ( ) -> fmap ( function ( FSObject $ obj ) use ( $ trans ) { if ( $ obj -> isFile ( ) ) { return $ trans ( $ obj ) ; } assert ( $ obj instanceof FixedFDirectory ) ; return $ obj -> cata ( $ trans ) ; } ) ) ; }
We could also use the catamorphism on this to do recursion as we have an unfix and an underlying fmap from the FDirectory .
58,789
public function foldFiles ( $ start_value , \ Closure $ fold_with ) { foreach ( $ this -> allFiles ( ) as $ file ) { $ start_value = $ fold_with ( $ start_value , $ file ) ; } return $ start_value ; }
Fold over all files in this directory and subjacent directories .
58,790
public function allFiles ( ) { return $ this -> cata ( function ( FSObject $ obj ) { if ( $ obj -> isFile ( ) ) { return array ( $ obj ) ; } assert ( $ obj instanceof FDirectory ) ; $ fcontents = $ obj -> fcontents ( ) ; if ( empty ( $ fcontents ) ) { return $ fcontents ; } return call_user_func_array ( "array_merge" ,...
Get a list of all files in the directory and subjacent directories .
58,791
protected function ensureAccess ( $ params = [ ] ) { if ( ! isset ( $ this -> checkAccess ) ) return ; $ params [ 'action' ] = $ this ; if ( call_user_func ( $ this -> checkAccess , $ params ) ) return ; $ user = \ Yii :: $ app -> user ; if ( $ user -> getIsGuest ( ) ) $ user -> loginRequired ( ) ; else throw new Forbi...
Ensure this action is allowed for current user
58,792
public static function detect ( $ html , & $ error = '' ) { if ( ! class_exists ( 'Whoops\Run' ) ) { return false ; } if ( strpos ( $ html , 'class="Whoops container"' ) != false ) { libxml_use_internal_errors ( true ) ; $ dom = new \ DOMDocument ( ) ; $ dom -> loadHTML ( $ html ) ; $ xpath = new \ DOMXpath ( $ dom ) ;...
Function detect Takes care of detecting if a Whoops error was passed and if true extracting the error code to return it by reference
58,793
public function getSwiftMessage ( ) { $ message = \ Swift_Message :: newInstance ( ) ; if ( true === is_array ( $ this -> getRecipient ( ) ) ) { $ recipient = $ this -> getRecipient ( ) ; } else { $ recipient = [ $ this -> getRecipient ( ) , ] ; } ; $ message -> setSubject ( $ this -> getSubject ( ) ) -> setFrom ( [ $ ...
Get Swift Message
58,794
private function checkMessageStatus ( $ message ) { if ( ! $ message || $ message -> success == 0 || $ message -> failure > 0 ) { throw new DispatchMessageException ( sprintf ( "%d messages could not be processed" , $ message -> failure ) ) ; } }
Checks message status
58,795
private function checkMessageResult ( $ message , \ ArrayIterator $ recipients ) { $ hasDeviceError = false ; $ recipientCount = $ recipients -> count ( ) ; for ( $ i = 0 ; $ i <= $ recipientCount ; $ i ++ ) { if ( isset ( $ message -> results [ $ i ] [ 'registration_id' ] ) ) { $ hasDeviceError = true ; $ recipients -...
Check message result
58,796
public function getOptional ( $ key , $ defaultValue = null ) { if ( array_key_exists ( $ key , $ this -> data ) ) { return $ this -> data [ $ key ] ; } return $ defaultValue ; }
Use this method for optional values .
58,797
protected function registerOptimizeCommand ( ) { $ this -> app -> bindShared ( 'command.optimize' , function ( $ app ) { return new \ Weloquent \ Core \ Console \ OptimizeCommand ( $ app [ 'composer' ] ) ; } ) ; }
Register the optimize command .
58,798
public static function listenTo ( String $ eventId , $ callback ) { if ( ! in_array ( gettype ( $ callback ) , [ 'array' , 'object' , 'closure' ] ) ) { return false ; } EventManager :: $ listeners [ $ eventId ] [ ] = $ callback ; }
Creates a new listener . Two parameters are required . The eventId that will be used to track the current event and the callback which can be either an array or a closure .
58,799
public function attachSubscriber ( Subscriber $ subscriber ) { $ listeners = $ subscriber -> getRegisteredEvents ( ) ; foreach ( $ listeners as $ id => $ listener ) { EventManager :: listenTo ( $ id , array ( $ subscriber , $ listener ) ) ; } }
This method attaches an event through it s subscribe object . List of events are loaded from the subscriber and added to the listeners .