idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
45,000
public function showAction ( Request $ request , Module $ entity ) { $ acl = $ this -> get ( 'bacon_acl.service.authorization' ) ; if ( ! $ acl -> authorize ( 'module' , 'SHOW' ) ) { throw $ this -> createAccessDeniedException ( ) ; } $ breadcumbs = $ this -> container -> get ( 'bacon_breadcrumbs' ) ; $ breadcumbs -> addItem ( [ 'title' => 'Module' , 'route' => 'module' , ] ) ; $ breadcumbs -> addItem ( [ 'title' => 'Details' , 'route' => '' , ] ) ; $ deleteForm = $ this -> createDeleteForm ( 'module_delete' , $ entity ) ; return [ 'entity' => $ entity , 'delete_form' => $ deleteForm -> createView ( ) , ] ; }
Finds and displays a Module entity .
45,001
public function deleteAction ( Module $ entity ) { $ acl = $ this -> get ( 'bacon_acl.service.authorization' ) ; if ( ! $ acl -> authorize ( 'module' , 'DELETE' ) ) { throw $ this -> createAccessDeniedException ( ) ; } $ handler = new ModuleFormHandler ( $ this -> createDeleteForm ( 'module_delete' , $ entity ) , $ this -> get ( 'doctrine' ) -> getManager ( ) , $ this -> get ( 'session' ) -> getFlashBag ( ) ) ; $ handler -> delete ( $ entity ) ; return $ this -> redirect ( $ this -> generateUrl ( 'module' ) ) ; }
Deletes a Module entity .
45,002
public static function createRedisByConfig ( array $ config ) { $ Redis = new Connection ( ) ; $ Redis -> setHost ( @ $ config [ 'host' ] ) -> setPort ( @ $ config [ 'port' ] ) ; ( isset ( $ config [ 'persistent' ] ) ) && $ Redis -> setPersistent ( $ config [ 'persistent' ] ) ; ( isset ( $ config [ 'connect_timeout' ] ) ) && $ Redis -> setConnectTimeout ( $ config [ 'connect_timeout' ] ) ; ( isset ( $ config [ 'connect_tries' ] ) ) && $ Redis -> setConnectTries ( $ config [ 'connect_tries' ] ) ; return $ Redis ; }
Create PhpRedis instance by array config
45,003
public function execute ( Framework $ framework , CliRequest $ request , Response $ response ) { $ this -> configure ( ) ; $ this -> configurationManager -> saveConfigurationFile ( ) ; $ dataSourceManager = $ framework -> getDataSourceManager ( ) ; foreach ( $ dataSourceManager -> getDataSourceTypeClasses ( ) as $ type ) { $ dataSource = $ dataSourceManager -> getDataSource ( $ type ) ; $ dataSource -> setup ( ) ; } }
Execute the installation of Turbo
45,004
protected function configure ( ) { $ configureSettingGroup = $ this -> cliHelper -> confirmAction ( 'Would you like to change the settings?' ) ; if ( ! $ configureSettingGroup ) { return ; } $ this -> configureSettings ( $ this -> configurationManager -> getSettings ( ) ) ; }
Iterates trough all configuration settings and asks the user for a value .
45,005
protected function configureSettings ( $ settings , $ path = '' ) { foreach ( $ settings as $ key => $ node ) { if ( is_array ( $ node ) ) { $ this -> configureSettings ( $ node , $ path . $ key . '.' ) ; } else { $ this -> configureSetting ( $ path . $ key , $ node ) ; } } }
Configures one settings group
45,006
protected function configureSetting ( $ path , $ value ) { $ newValue = $ this -> cliHelper -> inputText ( 'Please enter the value for "' . $ path . '":' , $ value ) ; if ( $ newValue === $ value ) { return ; } $ this -> configurationManager -> setSetting ( $ path , $ newValue ) ; }
Configures one setting
45,007
public function batchDelete ( $ id , MapsEngine_RasterCollectionsRasterBatchDeleteRequest $ postBody , $ optParams = array ( ) ) { $ params = array ( 'id' => $ id , 'postBody' => $ postBody ) ; $ params = array_merge ( $ params , $ optParams ) ; return $ this -> call ( 'batchDelete' , array ( $ params ) , "MapsEngine_RasterCollectionsRastersBatchDeleteResponse" ) ; }
Remove rasters from an existing raster collection .
45,008
public function onModules ( ModulesEvent $ event ) { $ saved = 0 ; $ model = $ event -> getTarget ( ) ; $ mapper = $ model -> getMapper ( ) ; $ modules = $ event -> getParams ( ) ; foreach ( $ modules as $ name => $ enabled ) { if ( empty ( $ name ) ) { continue ; } $ name = ( string ) $ name ; $ module = $ model -> findByName ( $ name ) ; if ( empty ( $ module ) ) { $ module = $ model -> create ( array ( 'module' => $ name , 'enabled' => $ enabled , ) ) ; } else { $ module -> enabled = $ enabled ; } $ saved += $ mapper -> save ( $ module ) ; } return $ saved ; }
Default action on modules - set event
45,009
public function load ( $ path , $ file = '.env' ) { try { $ env = new \ Dotenv \ Dotenv ( $ path , $ file ) ; $ env -> load ( ) ; return true ; } catch ( \ Dotenv \ Exception \ InvalidPathException $ e ) { return false ; } }
Load file . env .
45,010
public static function create ( $ kernel , $ filename , $ maxFiles = 0 , $ level = Logger :: DEBUG , $ bubble = true , $ filePermission = null , $ useLocking = false ) { return new RotatingFileHandler ( $ kernel -> getLogDir ( ) . DIRECTORY_SEPARATOR . $ filename , $ maxFiles , $ level , $ bubble , $ filePermission , $ useLocking ) ; }
Create the logger service .
45,011
public function send ( $ message , array $ options = [ ] ) { $ sms = new Message ( $ options ) ; $ this -> request ( 'sms' , $ sms -> getParams ( ) ) ; $ response = $ this -> getResponse ( ) ; if ( $ response [ 'error_code' ] !== '000' ) { $ this -> errors [ ] = $ response [ 'error_code' ] ; return false ; } return true ; }
Send a sms message
45,012
public function request ( $ url , array $ params = [ ] ) { $ curl = new Curl ( ) ; $ query = $ this -> buildQuery ( $ params ) ; $ curl -> setOptions ( $ this -> url . $ url , $ query , $ this -> port ) ; $ response = $ curl -> exec ( ) ; $ this -> setResponse ( $ response ) ; $ this -> setErrors ( $ response ) ; return $ this ; }
Send a curl request
45,013
public function buildQuery ( array $ params = [ ] ) { $ params = array_merge ( $ params , [ 'user_login' => $ this -> login , 'api_key' => $ this -> apiKey ] ) ; return http_build_query ( $ params ) ; }
Merge the credentials and params then returns the string query
45,014
protected function setErrors ( $ response ) { libxml_use_internal_errors ( true ) ; $ doc = new \ DOMDocument ( '1.0' , 'utf-8' ) ; $ doc -> loadXML ( $ response ) ; $ errors = libxml_get_errors ( ) ; if ( ! empty ( $ errors ) ) { $ this -> errors [ ] = 'Xml response is invalid' ; } return $ this ; }
Set the xml errors
45,015
public function getController ( Request $ request , array $ matched ) { if ( null !== $ request -> attributes -> get ( '_controller' ) ) { return $ this -> createController ( $ request -> attributes -> get ( '_controller' ) ) ; } if ( ! $ controller = $ matched [ '_controller' ] ) { throw new \ InvalidArgumentException ( 'Unable to look for controller as the "_controller" parameter is missing' ) ; } $ callable = $ this -> createController ( $ controller ) ; if ( ! is_callable ( $ callable ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Controller "%s" for URI "%s" is not callable.' , $ controller , $ request ) ) ; } return $ callable ; }
Get a callable controller
45,016
protected function createController ( $ controller ) { if ( false === strpos ( $ controller , '::' ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Unable to find controller "%s".' , $ controller ) ) ; } list ( $ class , $ method ) = explode ( '::' , $ controller , 2 ) ; if ( $ this -> container -> has ( $ class ) ) { $ controller = $ this -> container -> get ( $ class ) ; } else { if ( ! class_exists ( $ class ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Class "%s" does not exist.' , $ class ) ) ; } $ controller = new $ class ( ) ; } if ( $ controller instanceof ContainerAwareInterface ) { $ controller -> setContainer ( $ this -> container ) ; } return array ( $ controller , $ method ) ; }
Creates the callable from the controller string
45,017
public function getArguments ( Request $ request , array $ controller , array $ matched ) { $ reflection = new \ ReflectionMethod ( $ controller [ 0 ] , $ controller [ 1 ] ) ; $ attributes = $ request -> attributes -> all ( ) ; $ arguments = [ ] ; foreach ( $ reflection -> getParameters ( ) as $ param ) { if ( array_key_exists ( $ param -> name , $ matched ) ) { $ arguments [ ] = $ matched [ $ param -> name ] ; } elseif ( array_key_exists ( $ param -> name , $ attributes ) ) { $ arguments [ ] = $ attributes [ $ param -> name ] ; } elseif ( $ param -> isDefaultValueAvailable ( ) ) { $ arguments [ ] = $ param -> getDefaultValue ( ) ; } else { $ controller = sprintf ( '%s::%s()' , get_class ( $ controller [ 0 ] ) , $ controller [ 1 ] ) ; throw new \ RuntimeException ( sprintf ( 'Controller "%s" requires that you provide a value for the "$%s" argument (either because there is no default value, or because there is a non-optional argument after this one).' , $ controller , $ param -> name ) ) ; } } return $ arguments ; }
Get controller action arguments
45,018
public static function get ( $ post ) { $ post = is_a ( $ post , 'WP_Post' ) ? $ post : get_post ( $ post ) ; $ type = $ post -> post_type ; if ( 'page' === $ type ) { $ template_slug = get_page_template_slug ( $ post -> ID ) ; if ( ! empty ( $ template_slug ) ) { $ type .= '-' . wp_basename ( $ template_slug , '.php' ) ; } } return $ type ; }
Returns the type for the post the term template applies to what type of post is or what type of template is using .
45,019
public function postRegister ( RegisterRequest $ request ) { $ inputs = $ request -> except ( '_token' ) ; $ inputs [ 'password' ] = Hash :: make ( $ inputs [ 'password' ] ) ; $ user = $ this -> userRepo -> create ( $ inputs ) ; Event :: fire ( new UserHasCreated ( $ user ) ) ; return Redirect :: to ( '/' ) ; }
create a new user in DB
45,020
public function postLogin ( LoginRequest $ request ) { $ inputs = $ request -> except ( '_token' , 'rememberme' ) ; $ rememberme = $ request -> get ( 'rememberme' ) ; $ attemp = Auth :: attempt ( $ inputs , ! ! $ rememberme ) ; if ( ! $ attemp ) { $ request -> session ( ) -> flash ( 'error' , trans ( 'auth.failed' ) ) ; return Redirect :: back ( ) ; } return Redirect :: intended ( '/' ) ; }
try to login the user
45,021
protected function loadTemplates ( ) { $ templates = $ this -> templatesObjectBackend -> loadObject ( ) ; if ( ! is_array ( $ templates ) ) { $ templates = array ( ) ; } $ this -> templates = $ templates ; }
Loads the templates from the object backend
45,022
public function addTemplate ( $ key , $ file , $ priority = 10 ) { if ( ! file_exists ( $ file ) || ! is_readable ( $ file ) ) { return false ; } if ( ! isset ( $ this -> templates [ $ key ] ) || ! is_array ( $ this -> templates [ $ key ] ) ) { $ this -> templates [ $ key ] = array ( ) ; } $ this -> templates [ $ key ] [ $ priority ] = $ file ; ksort ( $ this -> templates [ $ key ] ) ; $ this -> saveTemplates ( ) ; return true ; }
Adds a new template file to the given key with the given priority .
45,023
public function removeTemplate ( $ key , $ file , $ priority = 10 ) { if ( ! isset ( $ this -> templates [ $ key ] [ $ priority ] ) ) { return false ; } unset ( $ this -> templates [ $ key ] [ $ priority ] ) ; }
Removes the template file for the given key and priority .
45,024
public function addRenderer ( RendererAbstract $ renderer ) { $ extension = $ renderer -> getExtension ( ) ; if ( isset ( $ this -> renderer [ $ extension ] ) ) { return false ; } $ this -> renderer [ $ extension ] = $ renderer ; return true ; }
Add a renderer .
45,025
public function renderTemplate ( $ key , $ additionalData = array ( ) ) { if ( ! isset ( $ this -> templates [ $ key ] ) ) { return '' ; } $ output = '' ; foreach ( $ this -> templates [ $ key ] as $ priority => $ templateFile ) { $ output .= $ this -> searchRendererAndRenderTemplate ( $ templateFile , $ additionalData ) ; } return $ output ; }
Renders all template files for the given template key .
45,026
protected function searchRendererAndRenderTemplate ( $ templateFile , $ additionalData = array ( ) ) { $ fileInfo = pathinfo ( $ templateFile ) ; $ extension = $ fileInfo [ 'extension' ] ; if ( ! isset ( $ this -> renderer [ $ extension ] ) ) { return '' ; } $ renderer = $ this -> renderer [ $ extension ] ; return $ renderer -> renderTemplateFile ( $ templateFile , $ this -> framework , $ this -> framework -> getRequest ( ) , $ this -> framework -> getResponse ( ) , $ additionalData ) ; }
Searches a renderer for the given template file and renders the file .
45,027
public static function load ( $ name ) { if ( substr ( $ name , 0 , 7 ) != 'csslib\\' ) return false ; $ filename = __DIR__ . '/src/' . implode ( '/' , array_slice ( explode ( '\\' , $ name ) , 1 ) ) . '.php' ; if ( ! file_exists ( $ filename ) ) throw new \ Exception ( 'File "' . $ filename . '" not found' ) ; require_once $ filename ; if ( class_exists ( $ name ) || interface_exists ( $ name ) ) return true ; throw new \ Exception ( 'Class or Interface "' . $ name . '" not exists' ) ; }
Load a class or interface by its name ain t that cool?
45,028
public static function load ( $ model = false ) { $ path = DOC_ROOT . Config :: get ( 'paths' , 'modules' ) ; if ( $ model && File :: isFile ( $ path . $ model . '.php' ) ) { $ array = explode ( '/' , $ model ) ; $ modelName = end ( $ array ) ; require $ path . $ model . '.php' ; return new $ modelName ( ) ; } return false ; }
Load a given model .
45,029
private function getImagePath ( $ path ) { if ( $ path && file_exists ( $ this -> filesystem -> getRootDir ( ) . $ path ) ) { return $ path ; } return $ this -> noImagePath ; }
Get image path .
45,030
public function set ( $ key , $ object ) { if ( ! is_object ( $ object ) ) { throw new \ InvalidArgumentException ( "Registry only accepts objects, given: " . gettype ( $ object ) ) ; } $ this -> _data [ $ key ] = $ object ; return $ this ; }
Sets an object .
45,031
public function add ( array $ items ) { foreach ( $ items as $ name => $ object ) { $ this -> set ( $ name , $ object ) ; } return $ this ; }
Adds an array of items .
45,032
public function get ( $ key ) { if ( isset ( $ this -> _data [ $ key ] ) ) { return $ this -> _data [ $ key ] ; } if ( isset ( $ this -> registered [ $ key ] ) ) { return $ this -> _data [ $ key ] = call_user_func ( $ this -> registered [ $ key ] , $ this ) ; } return null ; }
Returns a registered value .
45,033
public function exists ( $ key ) { return isset ( $ this -> _data [ $ key ] ) || isset ( $ this -> registered [ $ key ] ) ; }
Checks whether an key can be resolved to an object or registered closure .
45,034
protected function paginate ( Request $ request ) { $ fields = $ request -> input ( 'fields' ) ? explode ( ',' , $ request -> input ( 'fields' ) ) : [ '*' ] ; $ pageSize = $ request -> input ( 'pageSize' ) ? ( int ) $ request -> input ( 'pageSize' ) : null ; $ sort = $ request -> input ( 'sort' ) ? $ request -> input ( 'sort' ) : null ; $ order = $ request -> input ( 'order' ) ? $ request -> input ( 'order' ) : 'asc' ; $ pagination = $ this -> repository -> paginate ( $ pageSize , $ fields , $ sort , $ order ) ; $ pagination -> appends ( $ request -> except ( [ 'page' ] ) ) ; return Response :: apiResponse ( [ 'data' => $ pagination ] ) ; }
Retorna os resultados paginados .
45,035
public function update ( Request $ request , $ id ) { $ response = $ this -> repository -> update ( $ id , $ request -> all ( ) ) ; return Response :: apiResponse ( [ 'data' => $ response ] ) ; }
Atualiza os dados de uma entidade com base nos dados obtidos no Request .
45,036
private function getBundlesToBlend ( ) { $ toBlend = array ( ) ; foreach ( $ this -> config [ 'blend' ] as $ key => $ params ) { $ vendor = isset ( $ params [ 'vendor' ] ) ? $ params [ 'vendor' ] : null ; $ name = isset ( $ params [ 'name' ] ) ? $ params [ 'name' ] : null ; $ path = isset ( $ params [ 'path' ] ) ? $ params [ 'path' ] : null ; if ( ! $ vendor && ! $ name ) { list ( $ vendor , $ name ) = explode ( '/' , $ key , 2 ) ; } if ( ! isset ( $ toBlend [ $ vendor ] [ $ name ] ) ) { $ toBlend [ $ vendor ] [ $ name ] = $ path ; } } return $ toBlend ; }
Extract bundles to blend from config
45,037
private function blend ( $ toBlend , OutputInterface $ output ) { $ fs = new Filesystem ( ) ; $ vendorDir = $ this -> getContainer ( ) -> getParameter ( 'kernel.root_dir' ) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' ; foreach ( $ toBlend as $ vendor => $ names ) { foreach ( $ names as $ name => $ path ) { $ originPath = realpath ( $ vendorDir . DIRECTORY_SEPARATOR . $ vendor . DIRECTORY_SEPARATOR . $ name . DIRECTORY_SEPARATOR . ltrim ( $ path , DIRECTORY_SEPARATOR ) ) ; $ targetDir = realpath ( $ this -> bundlePath ) . DIRECTORY_SEPARATOR . $ vendor ; $ targetPath = $ targetDir . DIRECTORY_SEPARATOR . $ name ; if ( ! $ originPath ) { throw new \ InvalidArgumentException ( sprintf ( 'The origin path for "%s" does not exist : "%s"' , "$vendor/$name" , $ originPath ) ) ; } if ( ! $ fs -> exists ( $ targetDir ) ) { $ fs -> mkdir ( $ targetDir ) ; } if ( is_link ( $ targetPath ) && ( ! isset ( $ this -> config [ 'symlink' ] ) || ! $ this -> config [ 'symlink' ] ) || is_dir ( $ targetPath ) && isset ( $ this -> config [ 'symlink' ] ) && $ this -> config [ 'symlink' ] ) { $ fs -> remove ( $ targetPath ) ; } if ( isset ( $ this -> config [ 'symlink' ] ) && $ this -> config [ 'symlink' ] ) { $ fs -> symlink ( $ originPath , $ targetPath ) ; } else { $ fs -> mirror ( $ originPath , $ targetPath , null , array ( 'delete' => true , 'override' => true ) ) ; } $ output -> writeln ( sprintf ( 'The library <info>%s/%s</info> has been added' , $ vendor , $ name ) ) ; } } }
Blend bundles into prestaComposer vendor directory
45,038
public function setSpreadsheetQuery ( $ value ) { if ( $ value != null ) { $ this -> _params [ 'sq' ] = $ value ; } else { unset ( $ this -> _params [ 'sq' ] ) ; } return $ this ; }
Sets the spreadsheet key for this query .
45,039
public function setReverse ( $ value ) { if ( $ value != null ) { $ this -> _params [ 'reverse' ] = $ value ; } else { unset ( $ this -> _params [ 'reverse' ] ) ; } return $ this ; }
Sets the reverse attribute for this query .
45,040
public function size ( Int $ width , Int $ height ) : Thumb { $ this -> sets [ 'width' ] = $ width ; $ this -> sets [ 'height' ] = $ height ; return $ this ; }
Sets image size
45,041
public function resize ( Int $ width , Int $ height ) : Thumb { $ this -> sets [ 'rewidth' ] = $ width ; $ this -> sets [ 'reheight' ] = $ height ; return $ this ; }
Sets image resize
45,042
public function prosize ( Int $ width , Int $ height = 0 ) : Thumb { $ this -> sets [ 'prowidth' ] = $ width ; $ this -> sets [ 'proheight' ] = $ height ; return $ this ; }
Sets image proportional size
45,043
public function create ( String $ path = NULL ) : String { if ( isset ( $ this -> sets [ 'filePath' ] ) ) { $ path = $ this -> sets [ 'filePath' ] ; } $ this -> sets [ 'filters' ] = $ this -> filters ; $ settings = $ this -> sets ; $ this -> sets = [ ] ; return $ this -> image -> thumb ( $ path , $ settings ) ; }
Create new image
45,044
public function getProsize ( Int $ width = 0 , Int $ height = 0 ) { if ( ! isset ( $ this -> sets [ 'filePath' ] ) ) { return false ; } return $ this -> image -> getProsize ( $ this -> sets [ 'filePath' ] , $ width , $ height ) ; }
Get proportional size
45,045
public function getPathToLogFile ( $ name = 'm62' ) { if ( is_null ( $ this -> log_path ) ) { $ this -> log_path = realpath ( dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'logs' ) . DIRECTORY_SEPARATOR . $ name . '.log' ; } return $ this -> log_path ; }
Returns the path to the log file
45,046
public function removeLogFile ( ) { if ( file_exists ( $ this -> log_path ) ) { $ this -> logger = null ; unlink ( $ this -> log_path ) ; } return $ this ; }
Removes the logging file
45,047
protected function ensureListener ( $ listener ) { if ( $ listener instanceof ListenerInterface ) { return $ listener ; } if ( is_callable ( $ listener ) ) { return CallbackListener :: fromCallable ( $ listener ) ; } throw new InvalidArgumentException ( 'Listeners should be be ListenerInterface, Closure or callable. Received type: ' . gettype ( $ listener ) ) ; }
Ensure the input is a listener .
45,048
public function touchAction ( $ sessionId ) { if ( $ this -> request -> getHttpRequest ( ) -> getMethod ( ) !== 'POST' ) { $ this -> response -> setStatus ( 405 ) ; $ this -> response -> setHeader ( 'Allow' , 'POST' ) ; return ; } $ session = $ this -> sessionManager -> getSession ( $ sessionId ) ; if ( $ session !== NULL ) { $ session -> touch ( ) ; if ( $ this -> ssoLogger !== NULL ) { $ this -> ssoLogger -> log ( 'Touched session "' . $ sessionId . '"' , LOG_DEBUG ) ; } $ this -> view -> assign ( 'value' , array ( 'success' => TRUE ) ) ; } else { $ this -> response -> setStatus ( 404 ) ; $ this -> view -> assign ( 'value' , array ( 'error' => 'SessionNotFound' ) ) ; } }
Touch a session to refresh the last active timestamp
45,049
public function getRepositoryForEntity ( string $ entityName , string $ connectionName = null ) : AbstractRepository { $ repository = $ this -> loadFactorableInstance ( $ entityName ) ; if ( is_string ( $ connectionName ) ) { $ entityManager = $ this -> getContainer ( ) -> get ( 'doctrine' ) -> getManager ( $ connectionName ) ; $ repository -> setEntityManager ( $ entityManager ) ; } $ this -> onFactorableLoaded ( $ repository ) ; return $ repository ; }
Gets a repository for an entity
45,050
public function create ( ) { $ ssoClient = new \ Flowpack \ SingleSignOn \ Client \ Domain \ Model \ SsoClient ( ) ; if ( ( string ) $ this -> clientServiceBaseUri === '' ) { throw new Exception ( 'Missing Flowpack.SingleSignOn.Client.client.serviceBaseUri setting' , 1351075078 ) ; } $ ssoClient -> setServiceBaseUri ( $ this -> clientServiceBaseUri ) ; if ( ( string ) $ this -> clientPublicKeyFingerprint === '' ) { throw new Exception ( 'Missing Flowpack.SingleSignOn.Client.client.publicKeyFingerprint setting' , 1351075159 ) ; } $ ssoClient -> setPublicKeyFingerprint ( $ this -> clientPublicKeyFingerprint ) ; return $ ssoClient ; }
Build a SSO client instance from settings
45,051
private static function delimitString ( string $ string , string $ delimiter ) : string { $ output = [ ] ; if ( preg_match ( '/\A[a-z0-9]+\z/ui' , $ string ) && strtoupper ( $ string ) !== $ string ) { $ parts = self :: explodeOnCaps ( $ string ) ; } else { $ parts = self :: explodeOnDelims ( $ string ) ; } foreach ( $ parts as $ part ) { $ output [ ] = $ part . $ delimiter ; } return rtrim ( implode ( '' , $ output ) , $ delimiter ) ; }
Applies delimiter formatting to a string
45,052
private static function explodeOnCaps ( string $ string ) : array { $ string = preg_replace ( '/\B([A-Z])/' , '_\1' , $ string ) ; $ string = preg_replace ( '/([0-9]+)/' , '_\1' , $ string ) ; $ string = preg_replace ( '/_+/' , '_' , $ string ) ; $ string = trim ( $ string , '_' ) ; return explode ( '_' , $ string ) ; }
Splits a string into a list on capital letters
45,053
private static function explodeOnDelims ( string $ string ) : array { $ string = preg_replace ( '/[^a-z0-9]+/i' , '_' , $ string ) ; $ string = trim ( $ string , '_' ) ; return explode ( '_' , $ string ) ; }
Splits a string into a list on non - word breaks
45,054
public function get ( $ key = null ) { if ( $ key === null ) { return $ this ; } if ( ! isset ( $ this -> modules [ $ key ] ) ) { throw new ModuleDoesntExistException ( $ key ) ; } return $ this -> modules [ $ key ] ; }
Retrieve a registered module
45,055
private function insertMenuObject ( $ slug , $ callback , $ object ) { $ object -> slug = $ this -> snakeName ( $ slug ) ; $ object -> menu = $ this -> getMenu ( ) ; call_user_func ( $ callback , $ object ) ; if ( ! $ object -> insert ) { $ this -> links [ ] = $ object ; } }
Insert an object into the menu
45,056
protected function configureMetadata ( ) { $ this -> entityMetadata -> setCollection ( $ this -> collectionName ) ; if ( ! empty ( $ this -> primaryKey ) ) { $ this -> entityMetadata -> setPrimaryKey ( $ this -> primaryKey ) ; } }
Configure the metadata for the entity this repository interacts with
45,057
protected function sort ( $ items , $ type = self :: TYPE_BOTH , $ by = self :: KEY_NAME , $ direction = self :: ASC ) { $ returnArray = array ( ) ; if ( count ( $ items ) > 0 ) { $ tmpArray = array ( ) ; foreach ( $ items as $ key => $ value ) { $ tmpArray [ $ key ] = $ value [ $ by ] ; } natcasesort ( $ tmpArray ) ; if ( $ direction == self :: DESC ) { $ tmpArray = array_reverse ( $ tmpArray , true ) ; } foreach ( $ tmpArray as $ key => $ value ) { $ returnArray [ ] = $ items [ $ key ] ; } if ( $ by == self :: KEY_NAME && $ type == self :: TYPE_BOTH ) { $ files = array ( ) ; $ dirs = array ( ) ; foreach ( $ returnArray as $ value ) { if ( $ value [ self :: KEY_TYPE ] == self :: TYPE_FILE ) { $ files [ ] = $ value ; } elseif ( $ value [ self :: KEY_TYPE ] == self :: TYPE_DIR ) { $ dirs [ ] = $ value ; } } if ( $ direction == self :: DESC ) { $ returnArray = array_merge ( $ files , $ dirs ) ; } else { $ returnArray = array_merge ( $ dirs , $ files ) ; } } } return $ returnArray ; }
Order the results of a directory listing
45,058
public function get ( $ directory , $ type = self :: TYPE_BOTH , $ order = self :: KEY_NAME , $ direction = self :: ASC , $ limit = null , $ fileExtensions = array ( ) ) { $ items = array ( ) ; $ directory = rtrim ( $ directory , '/' ) ; if ( ! is_dir ( $ directory ) ) { throw new \ Exception ( 'Directory does not exist: ' . $ directory ) ; } $ directoryHandle = opendir ( $ directory ) ; while ( false !== ( $ file = readdir ( $ directoryHandle ) ) ) { if ( substr ( $ file , 0 , 1 ) != '.' ) { if ( is_dir ( $ directory . '/' . $ file ) && ( $ type == self :: TYPE_BOTH || $ type == self :: TYPE_DIR ) ) { $ items [ ] = array ( self :: KEY_TYPE => self :: TYPE_DIR , self :: KEY_NAME => $ file , self :: KEY_DATE => filemtime ( $ directory . '/' . $ file ) , self :: KEY_SIZE => filesize ( $ directory . '/' . $ file ) , self :: KEY_EXT => '' ) ; } else if ( is_file ( $ directory . '/' . $ file ) && ( $ type == self :: TYPE_BOTH || $ type == self :: TYPE_FILE ) ) { if ( ! count ( $ fileExtensions ) || in_array ( self :: getExtension ( $ file ) , $ fileExtensions ) ) { $ items [ ] = array ( self :: KEY_TYPE => self :: TYPE_FILE , self :: KEY_NAME => $ file , self :: KEY_DATE => filemtime ( $ directory . '/' . $ file ) , self :: KEY_SIZE => filesize ( $ directory . '/' . $ file ) , self :: KEY_EXT => self :: getExtension ( $ file ) ) ; } } } if ( $ limit && count ( $ items ) >= $ limit ) { break ; } } closedir ( $ directoryHandle ) ; $ items = $ this -> sort ( $ items , $ type , $ order , $ direction ) ; if ( $ this -> filterCallback ) { $ items = call_user_func ( $ this -> filterCallback , $ items ) ; } $ totalSize = 0 ; foreach ( $ items as $ item ) { $ totalSize += $ item [ self :: KEY_SIZE ] ; } $ this -> lastSize = $ totalSize ; $ this -> lastItemCount = count ( $ items ) ; return $ items ; }
Return the listing of a directory
45,059
protected function getExtension ( $ file ) { if ( strpos ( $ file , '.' ) !== false ) { $ tempExt = strtolower ( substr ( $ file , strrpos ( $ file , '.' ) + 1 , strlen ( $ file ) - strrpos ( $ file , '.' ) ) ) ; return strtolower ( trim ( $ tempExt , '/' ) ) ; } return '' ; }
Returns the extension of a file lowercase
45,060
public function actionTaskstatusindex ( ) { $ searchModel = new SRITaskstatusSearch ( ) ; $ dataProvider = $ searchModel -> search ( Yii :: $ app -> request -> queryParams ) ; return $ this -> render ( 'taskstatus_index' , [ 'searchModel' => $ searchModel , 'dataProvider' => $ dataProvider , ] ) ; }
Lists all SRITaskstatus models .
45,061
public function actionTaskstatuscreate ( ) { $ model = new SRI_Taskstatus ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { return $ this -> redirect ( [ 'taskstatusview' , 'id' => $ model -> id ] ) ; } else { return $ this -> render ( 'taskstatus_create' , [ 'model' => $ model , ] ) ; } }
Creates a new SRITaskstatus model . If creation is successful the browser will be redirected to the view page .
45,062
public function actionTaskstatusupdate ( $ id ) { $ model = $ this -> findTaskstatusmodel ( $ id ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { return $ this -> redirect ( [ 'taskstatusview' , 'id' => $ model -> id ] ) ; } else { return $ this -> render ( 'taskstatus_update' , [ 'model' => $ model , ] ) ; } }
Updates an existing SRITaskstatus model . If update is successful the browser will be redirected to the view page .
45,063
public function set ( $ target ) { if ( ! is_string ( $ target ) || empty ( $ target ) ) { throw new InvalidArgumentException ( 'Invalid target provided. Must be an non-empty string.' ) ; } $ this -> target = $ target ; }
Sets the target of upload .
45,064
public function references ( $ document ) { if ( $ this -> currentField ) { $ mapping = $ this -> class -> getFieldMapping ( $ this -> currentField ) ; $ dbRef = $ this -> dm -> createDBRef ( $ document , $ mapping ) ; if ( isset ( $ mapping [ 'simple' ] ) && $ mapping [ 'simple' ] ) { $ this -> query [ $ mapping [ 'name' ] ] = $ dbRef ; } else { $ keys = array ( 'ref' => true , 'id' => true , 'db' => true ) ; if ( isset ( $ mapping [ 'targetDocument' ] ) ) { unset ( $ keys [ 'ref' ] , $ keys [ 'db' ] ) ; } foreach ( $ keys as $ key => $ value ) { $ this -> query [ $ this -> currentField . '.$' . $ key ] = $ dbRef [ '$' . $ key ] ; } } } else { $ dbRef = $ this -> dm -> createDBRef ( $ document ) ; $ this -> query = $ dbRef ; } return $ this ; }
Checks that the value of the current field is a reference to the supplied document .
45,065
public static function apply ( $ object , array $ values ) { foreach ( $ values as $ property => $ value ) { if ( is_array ( $ value ) and ! isset ( $ value [ 0 ] ) ) { $ method = "get" . ucfirst ( $ property ) ; if ( method_exists ( $ object , $ method ) ) { static :: apply ( $ object -> { $ method } ( ) , $ value ) ; } } elseif ( is_array ( $ value ) and isset ( $ value [ 0 ] ) ) { $ method = "add" . ucfirst ( $ property ) ; if ( method_exists ( $ object , $ method ) ) { foreach ( $ value as $ arguments ) { if ( ! is_array ( $ arguments ) ) { $ arguments = array ( $ arguments ) ; } call_user_func_array ( array ( $ object , $ method ) , $ arguments ) ; } } } else { $ method = "set" . ucfirst ( $ property ) ; if ( method_exists ( $ object , $ method ) ) { $ object -> { $ method } ( $ value ) ; } } } }
This method applies a given set of values to a given object .
45,066
public static function validate ( $ object , array $ values , array $ constraints ) { $ errors = array ( ) ; $ validatorBuilder = new ValidatorBuilder ( ) ; $ validator = $ validatorBuilder -> getValidator ( ) ; foreach ( $ values as $ property => $ value ) { if ( ! isset ( $ constraints [ $ property ] ) ) { continue ; } if ( is_array ( $ value ) and ! isset ( $ value [ 0 ] ) ) { $ method = "get" . ucfirst ( $ property ) ; if ( method_exists ( $ object , $ method ) and array_key_exists ( $ property , $ constraints ) ) { $ results = static :: validate ( $ object -> { $ method } ( ) , $ value , $ constraints [ $ property ] ) ; if ( ! empty ( $ results ) ) { $ errors [ $ property ] = $ results ; } } } else { $ results = $ validator -> validateValue ( $ value , $ constraints [ $ property ] ) ; if ( $ results -> count ( ) > 0 ) { foreach ( $ results as $ result ) { $ errors [ $ property ] [ ] = $ result -> getMessage ( ) ; } } } } return $ errors ; }
This method will validate an object with the specified values .
45,067
public function redirect ( $ url , array $ params = [ ] , $ status = 302 ) { if ( ! empty ( $ params ) ) { $ url = rtrim ( preg_replace ( '/\?.*/' , '' , $ url ) , '/' ) ; $ url .= "?" . http_build_query ( $ params ) ; } $ this -> statusCode = $ status ; $ this -> headers -> set ( 'Location' , $ url ) ; $ this -> getMbAudit ( ) -> setResponseType ( 'redirect' ) ; $ this -> getMbAudit ( ) -> setResponseData ( [ 'url' => $ url , ] ) ; return true ; }
Redirect a page
45,068
protected function ajaxContent ( $ content ) { $ message = null ; $ this -> header ( 'Content-Type' , 'application/json' ) ; if ( $ content instanceof Arrayable ) { $ content = $ content -> toArray ( ) ; } elseif ( is_string ( $ content ) ) { $ content = [ 'content' => $ content ] ; } elseif ( ! is_array ( $ content ) && ! $ content instanceof \ Exception ) { return $ this -> ajaxContent ( new \ Exception ( "No valid content has been submitted!" , BaseResponse :: HTTP_BAD_REQUEST ) ) ; } elseif ( $ content instanceof \ Exception ) { $ this -> setStatusCode ( $ content -> getCode ( ) < 300 ? BaseResponse :: HTTP_BAD_REQUEST : $ content -> getCode ( ) ) ; $ message = $ content -> getMessage ( ) ; if ( $ content instanceof MbException ) { $ content = $ content -> getMessages ( ) ; } else { $ content = null ; } } $ this -> original = [ 'meta' => [ 'code' => $ this -> getStatusCode ( ) , 'message' => $ message , ] , 'data' => $ content , ] ; $ this -> getMbAudit ( ) -> setResponseType ( 'ajax' ) ; $ this -> getMbAudit ( ) -> setResponseData ( $ this -> original ) ; return $ this -> original ; }
Format content for json output
45,069
protected function htmlContent ( $ content ) { try { $ this -> getMbAudit ( ) -> setResponseType ( 'html' ) ; if ( $ content instanceof \ Exception ) { throw $ content ; } elseif ( $ content instanceof \ SplFileInfo && ! $ this -> getMbRequest ( ) -> isBlogAdmin ( ) ) { $ this -> downloadFile ( $ content ) ; } elseif ( ! is_string ( $ content ) && ! $ content instanceof Renderable ) { $ this -> getMbAudit ( ) -> setResponseType ( 'debug' ) ; $ this -> getMbAudit ( ) -> setResponseData ( $ content ) ; ob_start ( ) ; ( new Dumper ) -> dump ( $ content ) ; $ this -> original = ob_get_contents ( ) ; ob_end_clean ( ) ; } else { $ this -> getMbAudit ( ) -> setResponseData ( $ content ) ; $ this -> original = $ content ; } parent :: setContent ( $ this -> original ) ; } catch ( \ Exception $ e ) { $ this -> getMbAudit ( ) -> setResponseData ( $ e -> getMessage ( ) ) ; if ( $ this -> getMbRequest ( ) -> isBlogAdmin ( ) ) { $ this -> adminNotice ( $ e -> getMessage ( ) , 'error' ) ; } else { $ this -> original = "<strong>Erro:</strong> {$e->getMessage()}<br>" ; } parent :: setContent ( $ this -> original ) ; } }
Format content for html output
45,070
public function adminNotice ( $ message , $ type = 'success' ) { MbWPActionHook :: addActionCallback ( 'admin_notices' , function ( ) use ( $ message , $ type ) { echo self :: adminNoticeTemplate ( $ message , $ type ) ; } ) ; }
Post an admin notice on the dashboard
45,071
public function register ( Container $ container ) { $ container [ 'spot2.connections' ] = [ ] ; $ container [ 'spot2.connections.default' ] = null ; $ container [ 'spot2.config' ] = function ( Container $ container ) { $ config = new Config ( ) ; foreach ( $ container [ 'spot2.connections' ] as $ name => $ data ) { $ default = ( $ container [ 'spot2.connections.default' ] === $ name ) ? true : false ; $ config -> addConnection ( $ name , $ data , $ default ) ; } return $ config ; } ; $ container [ 'spot2.locator' ] = function ( Container $ container ) { return new Locator ( $ container [ 'spot2.config' ] ) ; } ; }
Register this provider .
45,072
public function actionEdit ( $ id ) { $ model = $ this -> findModel ( $ id ) ; $ form = new LanguageForm ( $ model ) ; if ( Yii :: $ app -> request -> isAjax && $ form -> load ( Yii :: $ app -> request -> post ( ) ) ) { if ( ! $ errors = ActiveForm :: validate ( $ form ) ) { try { $ this -> service -> edit ( $ form -> id , $ form ) ; $ this -> output [ 'status' ] = 1 ; } catch ( YiiException $ e ) { $ errors = ErrorHelper :: checkModel ( $ e -> data , $ form ) ; } } return $ this -> output [ 'errors' ] = $ errors ; } return $ this -> render ( 'edit' , [ 'model' => $ form ] ) ; }
Edites an existing Language model . If update is successful the browser will be redirected to the view page .
45,073
public static function getAuthSubTokenUri ( $ next , $ scope , $ secure = 0 , $ session = 0 , $ request_uri = self :: AUTHSUB_REQUEST_URI ) { $ querystring = '?next=' . urlencode ( $ next ) . '&scope=' . urldecode ( $ scope ) . '&secure=' . urlencode ( $ secure ) . '&session=' . urlencode ( $ session ) ; return $ request_uri . $ querystring ; }
Creates a URI to request a single - use AuthSub token .
45,074
public static function getAuthSubSessionToken ( $ token , $ client = null , $ request_uri = self :: AUTHSUB_SESSION_TOKEN_URI ) { $ client = self :: getHttpClient ( $ token , $ client ) ; if ( $ client instanceof Zend_Gdata_HttpClient ) { $ filterResult = $ client -> filterHttpRequest ( 'GET' , $ request_uri ) ; $ url = $ filterResult [ 'url' ] ; $ headers = $ filterResult [ 'headers' ] ; $ client -> setHeaders ( $ headers ) ; $ client -> setUri ( $ url ) ; } else { $ client -> setUri ( $ request_uri ) ; } try { $ response = $ client -> request ( 'GET' ) ; } catch ( Zend_Http_Client_Exception $ e ) { require_once 'Zend/Gdata/App/HttpException.php' ; throw new Zend_Gdata_App_HttpException ( $ e -> getMessage ( ) , $ e ) ; } if ( $ response -> isSuccessful ( ) ) { $ goog_resp = array ( ) ; foreach ( explode ( "\n" , $ response -> getBody ( ) ) as $ l ) { $ l = chop ( $ l ) ; if ( $ l ) { list ( $ key , $ val ) = explode ( '=' , chop ( $ l ) , 2 ) ; $ goog_resp [ $ key ] = $ val ; } } return $ goog_resp [ 'Token' ] ; } else { require_once 'Zend/Gdata/App/AuthException.php' ; throw new Zend_Gdata_App_AuthException ( 'Token upgrade failed. Reason: ' . $ response -> getBody ( ) ) ; } }
Upgrades a single use token to a session token
45,075
public static function AuthSubRevokeToken ( $ token , $ client = null , $ request_uri = self :: AUTHSUB_REVOKE_TOKEN_URI ) { $ client = self :: getHttpClient ( $ token , $ client ) ; if ( $ client instanceof Zend_Gdata_HttpClient ) { $ filterResult = $ client -> filterHttpRequest ( 'GET' , $ request_uri ) ; $ url = $ filterResult [ 'url' ] ; $ headers = $ filterResult [ 'headers' ] ; $ client -> setHeaders ( $ headers ) ; $ client -> setUri ( $ url ) ; $ client -> resetParameters ( ) ; } else { $ client -> setUri ( $ request_uri ) ; } ob_start ( ) ; try { $ response = $ client -> request ( 'GET' ) ; } catch ( Zend_Http_Client_Exception $ e ) { ob_end_clean ( ) ; require_once 'Zend/Gdata/App/HttpException.php' ; throw new Zend_Gdata_App_HttpException ( $ e -> getMessage ( ) , $ e ) ; } ob_end_clean ( ) ; if ( $ response -> isSuccessful ( ) ) { return true ; } else { return false ; } }
Revoke a token
45,076
public static function getAuthSubTokenInfo ( $ token , $ client = null , $ request_uri = self :: AUTHSUB_TOKEN_INFO_URI ) { $ client = self :: getHttpClient ( $ token , $ client ) ; if ( $ client instanceof Zend_Gdata_HttpClient ) { $ filterResult = $ client -> filterHttpRequest ( 'GET' , $ request_uri ) ; $ url = $ filterResult [ 'url' ] ; $ headers = $ filterResult [ 'headers' ] ; $ client -> setHeaders ( $ headers ) ; $ client -> setUri ( $ url ) ; } else { $ client -> setUri ( $ request_uri ) ; } ob_start ( ) ; try { $ response = $ client -> request ( 'GET' ) ; } catch ( Zend_Http_Client_Exception $ e ) { ob_end_clean ( ) ; require_once 'Zend/Gdata/App/HttpException.php' ; throw new Zend_Gdata_App_HttpException ( $ e -> getMessage ( ) , $ e ) ; } ob_end_clean ( ) ; return $ response -> getBody ( ) ; }
get token information
45,077
public static function getHttpClient ( $ token , $ client = null ) { if ( $ client == null ) { $ client = new Zend_Gdata_HttpClient ( ) ; } if ( ! $ client instanceof Zend_Gdata_HttpClient ) { require_once 'Zend/Gdata/App/HttpException.php' ; throw new Zend_Gdata_App_HttpException ( 'Client is not an instance of Zend_Gdata_HttpClient.' ) ; } $ useragent = 'Zend_Framework_Gdata/' . Zend_Version :: VERSION ; $ client -> setConfig ( array ( 'strictredirects' => true , 'useragent' => $ useragent ) ) ; $ client -> setAuthSubToken ( $ token ) ; return $ client ; }
Retrieve a HTTP client object with AuthSub credentials attached as the Authorization header
45,078
public function onDispatch ( SystemEvent $ event ) { $ server = $ this -> getServer ( ) ; $ request = $ server -> getRequest ( ) ; $ controllerName = $ request -> getAttribute ( 'controller' ) ; if ( ! $ controllerName ) { throw new RuntimeException ( 'Unable to dispatch the system event, the server request not ' . 'contains the "controller" attribute.' ) ; } $ actionName = $ request -> getAttribute ( 'action' , 'index' ) ; $ events = $ this -> getEvents ( ) ; $ controllers = $ this -> getControllers ( ) ; $ controller = $ controllers -> get ( $ controllerName ) ; $ event -> setContext ( $ controller ) ; $ dispatchEvent = new DispatchEvent ( $ controller , $ controllerName , $ actionName , $ event -> getParams ( ) ) ; $ events -> trigger ( $ dispatchEvent ) ; $ result = $ dispatchEvent -> getResult ( ) ; $ target = SystemEvent :: DISPATCH ; if ( $ result instanceof ResponseInterface ) { $ target = SystemEvent :: FINISH ; } $ event -> setResult ( $ target , $ result ) ; }
Triggers the DispatchEvent .
45,079
public function doDispatch ( DispatchEvent $ event ) { $ controller = $ event -> getContext ( ) ; $ action = $ event -> getParam ( 'action' ) . 'Action' ; $ server = $ this -> getServer ( ) ; $ request = $ server -> getRequest ( ) -> withAddedAttributes ( $ event -> getParams ( ) ) ; $ response = $ server -> getResponse ( ) ; $ result = call_user_func_array ( [ $ controller , $ action ] , [ $ request , $ response ] ) ; $ event -> setResult ( $ result ) ; }
Dispatch the controller .
45,080
protected function getTtlAndKey ( array & $ args ) { if ( is_numeric ( $ args [ 0 ] ) ) { $ ttl = ( int ) array_shift ( $ args ) ; $ key = $ this -> generateKey ( $ args ) ; } else { $ key = $ this -> generateKey ( $ args ) ; $ ttl = $ this -> ttl ; } return [ $ ttl , $ key ] ; }
Get TTL and unique key
45,081
public static function create ( $ eventName , $ eventArgs = null ) { if ( ! is_string ( $ eventName ) ) { throw new \ browserfs \ Exception ( 'Invalid argument $eventName: string expected!' ) ; } if ( null !== $ eventArgs && ! is_array ( $ eventArgs ) ) { throw new \ browserfs \ Exception ( 'Invalid argument $eventArgs: any[] | null expected' ) ; } return new static ( $ eventName , null === $ eventArgs ? [ ] : array_values ( $ eventArgs ) ) ; }
Creates a new event . Static constructor .
45,082
public function select ( $ table , $ fields , $ where = [ ] , $ options = [ ] ) { if ( is_scalar ( $ fields ) ) { $ fields = explode ( ',' , $ fields ) ; } $ query = new Select ( $ this , $ table , $ fields , new Where ( $ where ) , new Options ( $ options ) ) ; return $ query -> execute ( ) ; }
Select rows from a table .
45,083
public function fetch ( $ table , $ fields , $ where = null , $ options = [ ] ) { $ options [ 'limit' ] = 1 ; if ( ! isset ( $ options [ 'offset' ] ) ) { $ options [ 'offset' ] = 0 ; } $ result = $ this -> select ( $ table , $ fields , $ where , $ options ) ; foreach ( $ result as $ row ) { return $ row ; } }
Retrieve a single row from the database .
45,084
public function column ( $ table , $ field , $ where = null , $ options = null ) { $ results = $ this -> fetch ( $ table , $ field , $ where , $ options ) ; return array_shift ( $ results ) ; }
Retrieve a single value from a single column .
45,085
public function fetchObject ( $ class = null , $ table , $ fields , $ where = null , $ options = [ ] ) { if ( is_null ( $ class ) ) { $ class = 'StdClass' ; } elseif ( is_object ( $ class ) ) { $ class = get_class ( $ class ) ; } if ( is_scalar ( $ fields ) ) { $ fields = explode ( ',' , $ fields ) ; } $ query = new Select ( $ this , $ table , $ fields , new Where ( $ where ) , new Options ( $ options ) ) ; $ stmt = $ this -> prepare ( $ query -> __toString ( ) ) ; $ stmt -> execute ( $ query -> getBindings ( ) ) ; $ result = $ stmt -> fetchObject ( $ class ) ; if ( ! $ result ) { throw new SelectException ( $ stmt -> queryString ) ; } return $ result ; }
Retrieve a single row as an object .
45,086
public function update ( $ table , array $ fields , $ where , $ options = null ) { $ query = new Update ( $ this , $ table , $ fields , new Where ( $ where ) , new Options ( $ options ) ) ; return $ query -> execute ( ) ; }
Update one or more rows in the database .
45,087
public function delete ( $ table , array $ where ) { $ query = new Delete ( $ this , $ table , new Where ( $ where ) ) ; return $ query -> execute ( ) ; }
Delete a row from the database .
45,088
protected function getDependencies ( ) { return [ 'factories' => [ PermissionMiddleware :: class => PermissionMiddlewareFactory :: class , ExpressiveRouteName :: class => InvokableFactory :: class , PermissionMiddleware :: class => PermissionMiddlewareFactory :: class , ResourceResolver :: class => ResourceResolverAbstractFactory :: class , RoleResolver :: class => RoleResolverFactory :: class , AclMiddleware :: class => AclMiddlewareFactory :: class , Acl :: class => AclFromDataStoreFactory :: class , UserRepository :: class => UserRepositoryFactory :: class , GuestAuthentication :: class => GuestAuthenticationFactory :: class , RedirectMiddleware :: class => RedirectMiddlewareFactory :: class , GoogleClient :: class => GoogleClientFactory :: class , ] , 'aliases' => [ ConfigProvider :: AUTHENTICATION_MIDDLEWARE_SERVICE => AuthenticationMiddleware :: class , AuthenticationInterface :: class => 'authenticationServiceChain' , UserRepositoryInterface :: class => UserRepository :: class , self :: RULE_DATASTORE_SERVICE => AclRulesTable :: class , self :: ROLE_DATASTORE_SERVICE => AclRolesTable :: class , self :: RESOURCE_DATASTORE_SERVICE => AclResourceTable :: class , self :: PRIVILEGE_DATASTORE_SERVICE => AclPrivilegeTable :: class , self :: USER_DATASTORE_SERVICE => AclUsersTable :: class , self :: USER_ROLE_DATASTORE_SERVICE => AclUserRolesTable :: class , ] , 'abstract_factories' => [ ResourceResolverAbstractFactory :: class , RouteAttributeAbstractFactory :: class , RouteNameAbstractFactory :: class , MiddlewarePipeAbstractFactory :: class , AuthenticationChainAbstractFactory :: class , BasicAccessAbstractFactory :: class , PhpSessionAbstractFactory :: class , CredentialMiddlewareAbstractFactory :: class , ] , 'invokables' => [ PrivilegeResolver :: class => PrivilegeResolver :: class , AccessForbiddenHandler :: class => AccessForbiddenHandler :: class , ExpressiveRouteName :: class => ExpressiveRouteName :: class , ] , ] ; }
Returns the container dependencies
45,089
protected function getGeneratedProperties ( ) : array { $ reflectionObject = new \ ReflectionObject ( $ this ) ; $ properties = $ reflectionObject -> getProperties ( \ ReflectionProperty :: IS_PUBLIC ) ; $ result = [ ] ; foreach ( $ properties as $ property ) { if ( ! $ property -> isPublic ( ) || @ $ property -> isDefault ( ) ) { continue ; } $ result [ ] = $ property ; } return $ result ; }
Returns an array of generated public properties .
45,090
protected function removeGeneratedProperties ( ) { $ properties = $ this -> getGeneratedProperties ( ) ; foreach ( $ properties as $ property ) { $ name = $ property -> getName ( ) ; unset ( $ this -> { $ name } ) ; } }
Removes all generated public properties .
45,091
public static function namespace ( $ key , $ path ) { if ( ! array_key_exists ( $ key , self :: $ namespaces ) ) self :: $ namespaces [ $ key ] = $ path ; }
specifica di namespace per le path
45,092
public function render ( $ direct_output = true ) { if ( $ this -> exists ( ) == false ) return false ; extract ( $ this -> params ) ; ob_start ( ) ; include ( $ this -> filename ) ; $ content = ob_get_contents ( ) ; ob_end_clean ( ) ; foreach ( $ this -> engines as $ key => $ engine ) { $ content = $ engine -> map ( $ content , $ this -> params ) ; } if ( $ this -> can_clear ) { foreach ( ViewUtility :: find_rules ( $ content , '@section' , ')' ) as $ rule ) { $ content = str_replace ( $ rule , '' , $ content ) ; } } if ( $ direct_output ) { echo $ content ; return true ; } else return $ content ; }
genera la vista
45,093
public static function make ( $ filename , $ params = array ( ) , $ direct_output = true ) { $ view = new View ( $ filename , $ params ) ; return $ view -> render ( $ direct_output ) ; }
funzione statica per la generazione di viste immediate
45,094
public static function attribs ( $ attribs , $ leading_space = true ) { if ( ! Arr :: iterable ( $ attribs ) ) { return '' ; } $ out = array ( ) ; foreach ( $ attribs as $ k => $ v ) { $ v = ( is_array ( $ v ) ) ? join ( ' ' , $ v ) : $ v ; $ out [ ] = $ k . '="' . str_replace ( '"' , '\"' , $ v ) . '"' ; } return ( ( $ leading_space ) ? ' ' : '' ) . join ( ' ' , $ out ) ; }
Get a string of attributes given the attributes as an array
45,095
public static function image ( $ src , $ alt = null , $ attribs = array ( ) ) { $ attribs = array_merge ( array ( 'src' => $ src ) , $ attribs ) ; if ( $ alt ) { $ attribs [ 'alt' ] = htmlentities ( $ alt ) ; } return self :: tag ( 'img' , null , $ attribs ) ; }
Generate an img tag
45,096
public static function listy ( $ items , $ attribs = array ( ) , $ type = 'ul' ) { if ( ! Arr :: iterable ( $ items ) ) { return '' ; } $ htmls = array ( ) ; $ htmls [ ] = '<' . $ type . self :: attribs ( $ attribs ) . '>' ; foreach ( $ items as $ item ) { $ htmls [ ] = '<li>' . $ item . '</li>' ; } $ htmls [ ] = '</' . $ type . '>' ; return join ( "\n" , $ htmls ) ; }
Get an HTML list
45,097
public static function alisty ( $ items , $ attribs = array ( ) , $ type = 'ul' , $ active_title = null ) { if ( ! Arr :: iterable ( $ items ) ) { return '' ; } $ htmls = array ( ) ; $ htmls [ ] = '<' . $ type . self :: attribs ( $ attribs ) . '>' ; foreach ( $ items as $ title => $ href ) { $ body = ( is_array ( $ href ) ) ? Html :: a ( $ title , $ href ) : Html :: link ( $ href , $ title ) ; $ classes = array ( Str :: machine ( $ title ) ) ; if ( $ active_title === $ title ) { $ classes [ ] = 'active' ; } $ htmls [ ] = sprintf ( '<li class="%s">' , join ( ' ' , $ classes ) ) . $ body . '</li>' ; } $ htmls [ ] = '</' . $ type . '>' ; return join ( "\n" , $ htmls ) ; }
Get an HTML list of links
45,098
public static function selecty ( $ options , $ selected = null , $ attribs = array ( ) ) { $ htmls = array ( ) ; $ htmls [ ] = self :: select ( null , $ attribs , false ) ; if ( Arr :: iterable ( $ options ) ) { foreach ( $ options as $ value => $ title ) { $ option_attribs = array ( 'value' => $ value ) ; if ( ( string ) $ selected === ( string ) $ value ) { $ option_attribs [ 'selected' ] = 'selected' ; } $ htmls [ ] = self :: option ( $ title , $ option_attribs ) ; } } $ htmls [ ] = '</select>' ; return join ( "\n" , $ htmls ) ; }
Get a select list
45,099
public static function tably ( $ records ) { if ( count ( $ records ) === 0 ) { return null ; } $ htmls = array ( ) ; $ htmls [ ] = '<table>' ; foreach ( $ records as $ record ) { $ htmls [ ] = '<tr>' ; foreach ( $ record as $ k => $ v ) { $ htmls [ ] = sprintf ( '<td class="%s">%s</td>' , Str :: machine ( $ k ) , $ v ) ; } $ htmls [ ] = '</tr>' ; } $ htmls [ ] = '</table>' ; return join ( "\n" , $ htmls ) ; }
Get a table