idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
6,100
public function renderImage ( ) { $ rules = array ( ) ; foreach ( $ this -> rules as $ rule ) { $ rules [ ] = '[' . implode ( ", " , $ rule ) . ']' ; } $ this -> htmlOptions [ 'data-interchange' ] = implode ( ", " , $ rules ) ; return \ CHtml :: tag ( 'img' , $ this -> htmlOptions ) ; }
Renders the interchange image
6,101
private function createCreateForm ( User $ entity ) { $ form = $ this -> createForm ( new UserType ( ) , $ entity , array ( 'action' => $ this -> generateUrl ( 'admin_user_create' ) , 'method' => 'POST' , 'is_creation' => true ) ) ; $ form -> add ( 'submit' , 'submit' , array ( 'label' => 'Create' ) ) ; return $ form ; }
Creates a form to create a User entity .
6,102
public function editPasswordAction ( $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ user = $ em -> getRepository ( 'ChillMainBundle:User' ) -> find ( $ id ) ; if ( ! $ user ) { throw $ this -> createNotFoundException ( 'Unable to find User entity.' ) ; } $ editForm = $ this -> createEditPasswordForm ( $ user ) ; return $ this -> render ( 'ChillMainBundle:User:edit_password.html.twig' , array ( 'entity' => $ user , 'edit_form' => $ editForm -> createView ( ) ) ) ; }
Displays a form to edit the user password .
6,103
public function updatePasswordAction ( Request $ request , $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ user = $ em -> getRepository ( 'ChillMainBundle:User' ) -> find ( $ id ) ; if ( ! $ user ) { throw $ this -> createNotFoundException ( 'Unable to find User entity.' ) ; } $ editForm = $ this -> createEditPasswordForm ( $ user ) ; $ editForm -> handleRequest ( $ request ) ; if ( $ editForm -> isValid ( ) ) { $ password = $ editForm -> getData ( ) -> getPassword ( ) ; $ this -> get ( 'logger' ) -> debug ( 'update password for an user' , array ( 'method' => __METHOD__ , 'password' => $ password , 'user' => $ user -> getUsername ( ) ) ) ; $ this -> get ( 'logger' ) -> info ( 'update password for an user' , array ( 'method' => __METHOD__ , 'user' => $ user -> getUsername ( ) ) ) ; $ user -> setPassword ( $ this -> get ( 'security.password_encoder' ) -> encodePassword ( $ user , $ password ) ) ; $ em -> flush ( ) ; $ this -> addFlash ( 'success' , $ this -> get ( 'translator' ) -> trans ( 'Password successfully updated!' ) ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_user_edit' , array ( 'id' => $ id ) ) ) ; } return $ this -> render ( 'ChillMainBundle:User:edit_password.html.twig' , array ( 'entity' => $ user , 'edit_form' => $ editForm -> createView ( ) , ) ) ; }
Edits the user password
6,104
private function createDeleteLinkGroupCenterForm ( User $ user , GroupCenter $ groupCenter ) { return $ this -> createFormBuilder ( ) -> setAction ( $ this -> generateUrl ( 'admin_user_delete_group_center' , array ( 'uid' => $ user -> getId ( ) , 'gcid' => $ groupCenter -> getId ( ) ) ) ) -> setMethod ( 'DELETE' ) -> add ( 'submit' , 'submit' , array ( 'label' => 'Delete' ) ) -> getForm ( ) ; }
Creates a form to delete a link to a GroupCenter
6,105
private function createAddLinkGroupCenterForm ( User $ user ) { return $ this -> createFormBuilder ( ) -> setAction ( $ this -> generateUrl ( 'admin_user_add_group_center' , array ( 'uid' => $ user -> getId ( ) ) ) ) -> setMethod ( 'POST' ) -> add ( self :: FORM_GROUP_CENTER_COMPOSED , new ComposedGroupCenterType ( ) ) -> add ( 'submit' , 'submit' , array ( 'label' => 'Add a new groupCenter' ) ) -> getForm ( ) ; }
create a form to add a link to a groupcenter
6,106
public function getCallBack ( $ request , \ Exception $ exception ) { foreach ( $ this -> exceptionsCallbacks as $ callback ) { if ( is_callable ( $ callback ) ) { $ data = call_user_func ( $ callback , $ request , $ exception ) ; if ( ! is_null ( $ data ) ) { return $ data ; } } } }
Obtiene el callback de excepcion que se mostrara Entonces Se obtiene el pimer callback que cumpla con que retorne algo
6,107
public function setOrderByClause ( Clause \ OrderBy $ objOrderByClause ) { if ( $ this -> objOrderByClause ) { throw new Caller ( 'You can only have one OrderBy clause in a query.' ) ; } $ this -> objOrderByClause = $ objOrderByClause ; }
Sets the one order by clause allowed in a query . Stores it for delayed processing .
6,108
public function service ( $ service , $ subject , $ predicate = null , $ object = null ) { $ graphBuilder = $ this -> getGraphBuilder ( $ subject , $ predicate , $ object ) ; $ this -> services [ $ service ] = $ graphBuilder -> getSPARQL ( ) ; return $ this ; }
Adds the given graph or triple as an services condition .
6,109
public static function add ( $ title = null , $ url = [ 'action' => 'add' ] , $ icon = 'plus' , array $ options = [ ] ) { $ toolbar = Toolbar :: getInstance ( self :: $ _toolbar ) ; $ options += [ 'icon' => $ icon , 'button' => 'green lighten-2' ] ; $ toolbar -> appendButton ( 'Core.link' , $ title , $ url , $ options ) ; }
Create add link .
6,110
public static function apply ( $ title = null ) { $ toolbar = Toolbar :: getInstance ( self :: $ _toolbar ) ; $ title = ( empty ( $ title ) ) ? __d ( 'core' , 'Apply' ) : $ title ; $ toolbar -> appendButton ( 'Core.action' , $ title , self :: ACTION_APPLY , [ 'class' => 'jsFormButton' , 'icon' => 'check-square-o' , 'button' => 'green lighten-2' , ] ) ; }
Apply form button .
6,111
public static function cancel ( $ title = null , $ url = null , array $ options = [ ] ) { $ toolbar = Toolbar :: getInstance ( self :: $ _toolbar ) ; $ options += [ 'icon' => 'close' , 'iconClass' => 'ckTextRed' , 'button' => 'grey lighten-3' ] ; if ( empty ( $ url ) ) { $ url = [ 'action' => 'index' ] ; } $ title = ( empty ( $ title ) ) ? __d ( 'core' , 'Cancel' ) : $ title ; $ toolbar -> appendButton ( 'Core.link' , $ title , $ url , $ options ) ; }
Cancel form button .
6,112
public static function delete ( $ title = null ) { $ toolbar = Toolbar :: getInstance ( self :: $ _toolbar ) ; $ title = ( empty ( $ title ) ) ? __d ( 'core' , 'Delete' ) : $ title ; $ toolbar -> appendButton ( 'Core.action' , $ title , self :: ACTION_DELETE , [ ] ) ; }
Delete for process form .
6,113
public static function link ( $ title , $ url , array $ options = [ ] ) { $ toolbar = Toolbar :: getInstance ( self :: $ _toolbar ) ; $ options += [ 'icon' => 'link' , 'button' => 'grey lighten-3' ] ; $ toolbar -> appendButton ( 'Core.link' , $ title , $ url , $ options ) ; }
Create link output .
6,114
public static function save ( $ title = null ) { $ toolbar = Toolbar :: getInstance ( self :: $ _toolbar ) ; $ title = ( empty ( $ title ) ) ? __d ( 'core' , 'Save' ) : $ title ; $ toolbar -> appendButton ( 'Core.action' , $ title , self :: ACTION_SAVE , [ 'icon' => 'check' , 'class' => 'jsFormButton' , 'iconClass' => 'ckTextGreen' , 'button' => 'grey lighten-3' , ] ) ; }
Save form button .
6,115
protected function getConfig ( $ file = null ) { $ appConfig = $ this -> getServiceLocator ( ) -> get ( 'Config' ) ; if ( ! isset ( $ appConfig [ 'sphinxsearch' ] ) ) { throw new \ InvalidArgumentException ( 'Config not found with name: "sphinxsearch"' ) ; } else { $ config = new Config ( $ appConfig [ 'sphinxsearch' ] , true ) ; if ( ! is_null ( $ file ) ) { $ fileConfig = Factory :: fromFile ( $ file , true ) ; if ( ! isset ( $ fileConfig [ 'sphinxsearch' ] ) ) { throw new \ InvalidArgumentException ( 'Config not found with name: "sphinxsearch"' ) ; } $ config -> merge ( $ fileConfig [ 'sphinxsearch' ] ) ; } } return $ config ; }
Retrieve the config of sphinxsearch node
6,116
public function render ( \ DOMDocument $ domDocument ) { $ domElement = $ domDocument -> createElement ( "key" ) ; $ domElement -> setAttribute ( "x" , $ this -> x ) ; $ domElement -> setAttribute ( "color" , $ this -> color ) ; return $ domElement ; }
Render the SkyGradientKey
6,117
protected function createSettings ( ) { $ this -> graphSettings = new GraphSettings ( $ this ) ; $ this -> addScriptFeature ( $ this -> graphSettings ) ; return $ this -> graphSettings ; }
Create new graph settings
6,118
public function choices ( ) : HasMany { return $ this -> hasMany ( \ Iocaste \ Microservice \ Foundation \ Data \ Models \ Parameter \ Choice :: class ) ; }
One - to - Many Relationship One Parameter has Many Choices .
6,119
public static function get ( $ key , $ default = null ) { if ( ! isset ( CCServer :: $ _instance -> COOKIE [ $ key ] ) ) { return $ default ; } return CCServer :: $ _instance -> COOKIE [ $ key ] ; }
get a cookie
6,120
public static function once ( $ key ) { if ( ! is_null ( static :: get ( $ key ) ) ) { $ cookie = static :: get ( $ key ) ; static :: delete ( $ key ) ; return $ cookie ; } }
eat a cookie means get it once
6,121
public function get ( $ command ) { $ className = ucfirst ( $ command ) ; $ className = "PortaText\\Command\\Api\\$className" ; if ( ! class_exists ( $ className ) ) { throw new \ InvalidArgumentException ( "Command $command does not exist" ) ; } return new $ className ( ) ; }
Returns a command instance based on the command name requested .
6,122
protected static function __chomp ( string $ toChomp , string $ string ) : string { $ chomp = Lambda :: compose ( self :: lchomp ( $ toChomp ) , self :: rchomp ( $ toChomp ) ) ; return $ chomp ( $ string ) ; }
Two - Sided Chomp
6,123
public function getStorageFactory ( ) : ? Factory { if ( ! $ this -> hasStorageFactory ( ) ) { $ this -> setStorageFactory ( $ this -> getDefaultStorageFactory ( ) ) ; } return $ this -> storageFactory ; }
Get storage factory
6,124
public function getField ( $ position ) { if ( ! isset ( $ this -> fields [ $ position ] ) ) { switch ( $ position ) { case 0 : $ this -> fields [ $ position ] = new SecondsField ( ) ; break ; case 1 : $ this -> fields [ $ position ] = new MinutesField ( ) ; break ; case 2 : $ this -> fields [ $ position ] = new HoursField ( ) ; break ; case 3 : $ this -> fields [ $ position ] = new DayOfMonthField ( ) ; break ; case 4 : $ this -> fields [ $ position ] = new MonthField ( ) ; break ; case 5 : $ this -> fields [ $ position ] = new DayOfWeekField ( ) ; break ; default : throw new InvalidArgumentException ( $ position . ' is not a valid position' ) ; } } return $ this -> fields [ $ position ] ; }
Get an instance of a field object for a cron expression position
6,125
final public function hasFile ( $ file ) { $ helloReflection = new \ ReflectionClass ( $ this ) ; $ dir = dirname ( $ helloReflection -> getFilename ( ) ) ; if ( file_exists ( $ dir . '/' . $ file ) ) { return $ dir . '/' . $ file ; } return false ; }
framework has file?
6,126
public function dim ( Response $ response , $ target ) { $ img = $ this -> getImageManager ( ) -> make ( $ target ) ; $ response -> setDim ( $ img -> getWidth ( ) . 'x' . $ img -> getHeight ( ) ) ; }
return image dimensions .
6,127
public function setAdditionalImages ( array $ additionalImages ) { $ resolver = new OptionsResolver ( ) ; $ this -> configureAdditionalImage ( $ resolver ) ; $ this -> additionalImages = $ additionalImages ; foreach ( $ additionalImages as $ additionalImage ) { $ this -> addAdditionalImage ( $ additionalImage , $ resolver ) ; } return $ this ; }
set Additional Images .
6,128
protected function addAdditionalImage ( array $ additionalImage , OptionsResolver $ resolver ) { $ image = $ resolver -> resolve ( $ additionalImage ) ; $ this -> additionalImages [ $ image [ 'prefix' ] ] = $ image ; return $ this ; }
add Additional Image .
6,129
protected function configureAdditionalImage ( OptionsResolver $ resolver ) { $ resolver -> setRequired ( [ 'prefix' , 'width' , 'height' ] ) -> setOptional ( [ 'mode' ] ) -> setDefaults ( [ 'mode' => 'fit' ] ) -> addAllowedTypes ( [ 'prefix' => 'string' , 'mode' => 'string' , 'width' => 'integer' , 'height' => 'integer' , ] ) -> addAllowedValues ( [ 'mode' => [ 'crop' , 'resize' , 'fit' ] ] ) ; return $ this ; }
configure Additional Image .
6,130
private function copyDir ( Response $ response , $ target , $ dst , $ newFolder = '' ) { $ folder = trim ( strrchr ( $ target , DIRECTORY_SEPARATOR ) , DIRECTORY_SEPARATOR ) ; $ newFolder = $ newFolder ? : $ dst . DIRECTORY_SEPARATOR . $ folder ; if ( file_exists ( $ newFolder ) ) { throw new ExistsException ( sprintf ( 'folder "%s" exists' , $ newFolder ) ) ; } mkdir ( $ newFolder ) ; $ response -> addAdded ( $ this -> getFileInfo ( $ newFolder ) ) ; foreach ( glob ( $ target . '/*' ) as $ name ) { if ( is_dir ( $ name ) ) { $ this -> copyDir ( $ response , $ name , $ newFolder ) ; } else { $ filename = $ newFolder . DIRECTORY_SEPARATOR . $ this -> basename ( $ name ) ; copy ( $ name , $ filename ) ; $ response -> addAdded ( $ this -> getFileInfo ( $ filename ) ) ; } } }
copy dir and all inside .
6,131
private function isShowFile ( $ name , $ showHidden = false ) { $ response = true ; if ( $ name == '.' || $ name == '..' || ( ! $ showHidden && strpos ( $ name , '.' ) === 0 ) ) { $ response = false ; } return $ response ; }
is Show File .
6,132
private function getFileInfo ( $ file ) { if ( ! file_exists ( $ file ) ) { throw new NotFoundException ( sprintf ( 'file "%s" not found' , $ file ) ) ; } $ fileStat = stat ( $ file ) ; $ directory = dirname ( $ file ) == '.' ? '' : dirname ( $ file ) ; $ fileInfo = new FileInfo ( $ this -> basename ( $ file ) , $ this -> getDriverId ( ) , $ fileStat [ 'mtime' ] , $ directory ) ; $ fileInfo -> setSize ( $ fileStat [ 'size' ] ) ; $ fileInfo -> setWrite ( is_writable ( $ file ) ) ; $ fileInfo -> setMime ( $ this -> getMimeType ( $ file ) ) ; $ fileInfo -> setLocked ( $ this -> driverOptions [ 'locked' ] ) ; $ this -> setDirs ( $ fileInfo , $ file ) ; $ tmb = $ this -> getThumb ( $ file ) ; if ( ! file_exists ( $ tmb ) && in_array ( $ fileInfo -> getMime ( ) , [ 'image/jpeg' , 'image/png' , 'image/gif' ] ) ) { $ fileInfo -> setTmb ( 1 ) ; } elseif ( file_exists ( $ tmb ) ) { $ fileInfo -> setTmb ( DIRECTORY_SEPARATOR . $ tmb ) ; } return $ fileInfo ; }
get file info by full path file name .
6,133
private function getMimeType ( $ file ) { $ type = FileInfo :: DIRECTORY_MIME_TYPE ; if ( is_file ( $ file ) ) { if ( class_exists ( 'finfo' ) ) { $ finfo = new \ finfo ( FILEINFO_MIME ) ; $ type = $ finfo -> file ( $ file ) ; } else { $ type = MimeType :: getTypeByExt ( pathinfo ( $ file , PATHINFO_EXTENSION ) ) ; } } $ type = strstr ( $ type , ';' , true ) ? : $ type ; return isset ( MimeType :: $ internalType [ $ type ] ) ? MimeType :: $ internalType [ $ type ] : $ type ; }
get Mime Type by File .
6,134
private function scanDir ( $ dir , $ onlyDir = 0 ) { $ files = array ( ) ; foreach ( glob ( $ dir . '/*' , $ onlyDir ) as $ name ) { if ( $ this -> isShowFile ( $ name , $ this -> driverOptions [ 'showHidden' ] ) ) { $ file = $ this -> getFileInfo ( $ name ) ; $ this -> setDirs ( $ file , $ name ) ; $ files [ ] = $ file ; } } return $ files ; }
get Files by dir name .
6,135
public function update ( $ now ) { if ( $ now >= ( $ this -> lastCallTime + $ this -> interval ) ) { $ this -> lastCallTime = $ now ; $ this -> callNow ( ) ; } }
Updates that timer if is after next call its calls callback .
6,136
public function search ( $ query , $ language = null , $ group = null ) { $ url = sprintf ( 'products/search/%s?%s' , $ query , http_build_query ( [ 'lang' => $ language , 'g' => $ group , 'page' => 1 , ] ) ) ; return $ this -> request ( $ url ) ; }
search packages .
6,137
public function show ( $ language , $ product ) { return $ this -> request ( sprintf ( 'products/%s/%s' , $ language , $ this -> transform ( $ product ) ) ) ; }
detailed information for specific package .
6,138
public function followStatus ( $ language , $ product ) { return $ this -> request ( sprintf ( 'products/%s/%s/follow' , $ language , $ this -> transform ( $ product ) ) ) ; }
check your following status .
6,139
public function follow ( $ language , $ product ) { return $ this -> request ( sprintf ( 'products/%s/%s/follow' , $ language , $ this -> transform ( $ product ) ) , 'POST' ) ; }
follow your favorite software package .
6,140
public function unfollow ( $ language , $ product ) { return $ this -> request ( sprintf ( 'products/%s/%s/follow' , $ language , $ this -> transform ( $ product ) ) , 'DELETE' ) ; }
unfollow given software package .
6,141
public function references ( $ language , $ product ) { return $ this -> request ( sprintf ( 'products/%s/%s/references?page=%d' , $ language , $ this -> transform ( $ product ) , 1 ) ) ; }
shows all references for the given package .
6,142
public function versions ( $ language , $ product ) { return $ this -> request ( sprintf ( 'products/%s/%s/versions' , $ language , $ this -> transform ( $ product ) ) ) ; }
shows all version for the given package .
6,143
public static function bindBehavior ( $ name , array $ config = [ ] ) { list ( $ model , $ class ) = static :: _classesForBehavior ( $ name ) ; static :: _initializeBehaviors ( ) ; if ( is_object ( $ name ) ) { $ name -> config ( $ config ) ; } else { if ( ! class_exists ( $ class ) ) { $ message = "Behavior class `{$class}` does not exist. " ; $ message .= "Its name might be misspelled. Behavior was requested by " ; $ message .= "model `{$model}`." ; throw new Exception ( $ message ) ; } $ name = new $ class ( $ config + compact ( 'model' ) ) ; } static :: $ _behaviors [ $ model ] [ $ class ] = $ name ; }
Binds a new instance of a behavior to the model using given config or entirely replacing an existing behavior instance with new config .
6,144
public static function unbindBehavior ( $ name ) { list ( $ model , $ class ) = static :: _classesForBehavior ( $ name ) ; static :: _initializeBehaviors ( ) ; if ( ! isset ( static :: $ _behaviors [ $ model ] [ $ class ] ) ) { throw new RuntimeException ( "Behavior `{$class}` not bound to model `{$model}`." ) ; } unset ( static :: $ _behaviors [ $ model ] [ $ class ] ) ; }
Unbinds an instance of a behavior from the model . Will throw an exception if behavior is not bound .
6,145
public static function hasBehavior ( $ name ) { static :: _initializeBehaviors ( ) ; try { list ( $ model , $ class ) = static :: _classesForBehavior ( $ name ) ; } catch ( Exception $ e ) { return false ; } return isset ( static :: $ _behaviors [ $ model ] [ $ class ] ) ; }
Allows to check if a certain behavior is bound to the model .
6,146
protected static function _classesForBehavior ( $ name ) { $ model = get_called_class ( ) ; if ( is_object ( $ name ) ) { $ class = get_class ( $ name ) ; } elseif ( ! $ class = Libraries :: locate ( 'behavior' , $ name ) ) { throw new RuntimeException ( "No behavior named `{$name}` found." ) ; } return [ $ model , $ class ] ; }
Helper method to retrieve current model class and behavior class for name .
6,147
protected function listen ( string $ event , string $ methodName , int $ priority = 0 ) : EventListener { return new EventListener ( $ event , [ $ this , $ methodName ] , $ priority ) ; }
Create an event listener and map it to a method of this class
6,148
public function getPscType ( $ dcTypeConstant ) { if ( $ dcTypeConstant === NULL ) throw new TypeConversionException ( 'dcTypeConstant kann nicht NULL sein' ) ; $ flip = array_flip ( $ this -> casts ) ; if ( ! array_key_exists ( $ dcTypeConstant , $ flip ) ) { throw TypeConversionException :: typeTarget ( 'Doctrine-Type: ' . $ dcTypeConstant , 'Psc-Type' ) ; } return Type :: create ( $ flip [ $ dcTypeConstant ] ) ; }
Wandelt einen Doctrine Type in einen Psc Type um
6,149
protected static function checkMatchingArguments ( $ returnValues , $ arguments ) { foreach ( $ returnValues as $ currentMethodArguments => $ currentMethod ) { if ( strpos ( $ currentMethodArguments , 'Hamcrest\\' ) === false ) { continue ; } $ hamcrest = unserialize ( $ currentMethodArguments ) ; try { foreach ( $ arguments as $ index => $ arg ) { if ( ! array_key_exists ( $ index , $ hamcrest ) ) { throw new AssertionError ( 'not enough hamcrest indexes' ) ; } if ( $ hamcrest [ $ index ] instanceof Matcher ) { assertThat ( $ arg , $ hamcrest [ $ index ] ) ; } else if ( $ arg != $ hamcrest [ $ index ] ) { throw new AssertionError ( ) ; } } } catch ( AssertionError $ e ) { continue ; } return $ currentMethodArguments ; } return NULL ; }
Checking if there is a matching Hamcrest Function in case of founding returns the Hamcrest object otherwise returns NULL
6,150
public function assetPath ( $ source , $ type = null ) { $ ext = FS :: ext ( $ source ) ; $ type = ( empty ( $ type ) ) ? $ ext : $ type ; $ path = FS :: clean ( WWW_ROOT . '/' . $ source , '/' ) ; if ( FS :: isFile ( $ path ) ) { return $ path ; } $ path = FS :: clean ( WWW_ROOT . '/' . $ type . '/' . $ source , '/' ) ; if ( FS :: isFile ( $ path ) ) { return $ path ; } $ path = $ this -> _findPluginAsset ( $ source , $ type ) ; return $ path ; }
Get absolute asset path .
6,151
protected function _findPluginAsset ( $ source , $ type = null ) { list ( $ plugin , $ path ) = pluginSplit ( $ source ) ; $ plugin = ( string ) $ plugin ; if ( Plugin :: loaded ( $ plugin ) ) { $ plgPath = implode ( '/' , [ Plugin :: path ( $ plugin ) , Configure :: read ( 'App.webroot' ) , $ type , $ path ] ) ; $ plgPath = FS :: clean ( $ plgPath , '/' ) ; if ( FS :: isFile ( $ plgPath ) ) { return $ plgPath ; } } return false ; }
Find plugin assets by source .
6,152
public function getQueueFactory ( ) : ? Factory { if ( ! $ this -> hasQueueFactory ( ) ) { $ this -> setQueueFactory ( $ this -> getDefaultQueueFactory ( ) ) ; } return $ this -> queueFactory ; }
Get queue factory
6,153
public static function instance ( $ set = null ) { if ( is_null ( $ set ) ) { return static :: $ _instance ; } if ( ! $ set instanceof CCIn_Instance ) { throw new \ InvalidArgumentException ( 'CCIn::set() - only CCIn_Instance object can be passed.' ) ; } static :: $ _instance = $ set ; }
get the current input instance
6,154
public static function create ( $ get , $ post , $ cookie , $ files , $ server ) { return new CCIn_Instance ( $ get , $ post , $ cookie , $ files , $ server ) ; }
create new instance assign the main vars GET POST COOKIE FILES SERVER here
6,155
public function getTables ( ) { $ objResult = $ this -> query ( "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = current_schema() AND TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_NAME ASC" ) ; $ strToReturn = array ( ) ; while ( $ strRowArray = $ objResult -> fetchRow ( ) ) { array_push ( $ strToReturn , $ strRowArray [ 0 ] ) ; } return $ strToReturn ; }
Returns the list of tables in the database as string
6,156
public function dispatch ( $ action , ServerRequestInterface $ request ) : ResponseInterface { $ this -> getLogger ( ) -> debug ( 'dispatching to action: ' . $ action ) ; if ( ! method_exists ( $ this , $ action ) && ! method_exists ( $ this , '__call' ) ) { throw new ActionDoesNotExistException ( ) ; } $ response = $ this -> $ action ( $ request ) ; return $ response ; }
function to dispatch requests coming through the router
6,157
public function getDefaultAuth ( ) : ? Guard { $ manager = Auth :: getFacadeRoot ( ) ; if ( isset ( $ manager ) ) { return $ manager -> guard ( ) ; } return $ manager ; }
Get a default auth value if any is available
6,158
protected function get_script_path ( ) { if ( null == $ this -> script_path ) { $ class_name = substr ( get_called_class ( ) , strrpos ( get_called_class ( ) , '\\' ) + 1 ) ; $ this -> script_path = $ this -> get_dir ( ) . '/' . $ class_name . '.phtml' ; } return $ this -> script_path ; }
Get the full path to the template file .
6,159
protected function createEntry ( ) { $ entry = new Entry ( ) ; $ entry -> setVisible ( false ) -> setName ( $ this -> name ) ; $ this -> setEntry ( $ entry ) ; return $ entry ; }
Create the hidden Entry
6,160
public function getDefaultSession ( ) : ? Session { $ manager = SessionFacade :: getFacadeRoot ( ) ; if ( isset ( $ manager ) ) { return $ manager -> driver ( ) ; } return $ manager ; }
Get a default session value if any is available
6,161
final public function getOption ( $ name ) { if ( ! isset ( $ this -> options [ $ name ] ) ) { throw new \ LogicException ( sprintf ( 'The option "%s" don\'t exists.' , $ name ) ) ; } return $ this -> options [ $ name ] ; }
Get option value from name
6,162
public static function string2class ( $ stringValue ) { $ stringValue = trim ( $ stringValue ) ; if ( $ stringValue === '' ) { return $ stringValue ; } if ( Preg :: match ( $ stringValue , '/^[A-Z0-9]+$/' ) ) { return mb_strtolower ( $ stringValue ) ; } $ specials = preg_quote ( implode ( "" , array ( '.' , '@' , '\\' , ' ' , '[' , ']' , '(' , ')' ) ) , '/' ) ; $ stringValue = Preg :: replace ( $ stringValue , sprintf ( '/%s|[%s]/' , "(?<=\w)([A-Z]|[0-9])" , $ specials ) , '-\\1' ) ; $ stringValue = mb_strtolower ( $ stringValue ) ; return $ stringValue ; }
Erstells aus einem CamelCase Namen oder einer Klasse oder einem String eine html - klasse
6,163
protected function request ( $ url , $ method = 'GET' , array $ params = [ ] ) { $ url = $ this -> sanitizeQuery ( $ url ) ; $ response = $ this -> client -> request ( $ method , $ url , $ params ) ; if ( is_array ( $ response ) && isset ( $ response [ 'paging' ] ) ) { $ response = $ this -> injectPager ( $ response , $ method , $ url , $ params ) ; } return $ response ; }
performs the request .
6,164
private function sanitizeQuery ( $ query ) { $ parts = parse_url ( $ query ) ; $ path = $ parts [ 'path' ] ; if ( ! isset ( $ parts [ 'query' ] ) ) { return $ query ; } $ vars = explode ( '&' , $ parts [ 'query' ] ) ; $ final = [ ] ; if ( ! empty ( $ vars ) ) { foreach ( $ vars as $ var ) { $ parts = explode ( '=' , $ var ) ; $ key = $ parts [ 0 ] ; $ val = $ parts [ 1 ] ; if ( ! array_key_exists ( $ key , $ final ) && ! empty ( $ val ) ) { $ final [ $ key ] = $ val ; } } } return $ path . '?' . http_build_query ( $ final ) ; }
removes empty query string parameters .
6,165
private function injectPager ( array $ response , $ method , $ url , array $ params = [ ] ) { while ( next ( $ response ) ) { if ( 'paging' === key ( $ response ) ) { prev ( $ response ) ; break ; } } $ pageableKey = key ( $ response ) ; $ response [ $ pageableKey ] = new Pager ( $ response , $ pageableKey , $ this -> client , $ method , $ url , $ params ) ; reset ( $ response ) ; return $ response ; }
converts the pageable data into a real pager .
6,166
public function addProvider ( $ provider ) { if ( ! in_array ( $ provider , $ this -> getServiceProviders ( ) ) ) { $ quote = $ this -> getQuoteType ( 'providers' ) ; $ separator = $ this -> getArrayItemsSeparator ( 'providers' ) ; $ anchor = $ this -> getInsertPoint ( 'providers' ) ; $ insert = $ separator . $ quote . $ provider . $ quote . ',' ; $ this -> write ( $ insert , $ anchor ) ; } }
Add specified provider .
6,167
protected function isCharInComment ( $ haystack , $ charPosition ) { for ( $ c = $ charPosition ; $ c > 0 ; -- $ c ) { if ( $ haystack [ $ c ] === PHP_EOL ) { break ; } elseif ( $ haystack [ $ c ] === '#' or ( $ haystack [ $ c ] === '/' and ( $ haystack [ $ c + 1 ] === '/' or $ haystack [ $ c - 1 ] === '/' ) ) ) { return true ; } } $ openingsCount = 0 ; $ closingsCount = 0 ; for ( $ c = $ charPosition ; $ c > 0 ; -- $ c ) { if ( $ haystack [ $ c ] === '*' and $ haystack [ $ c - 1 ] === '/' ) { ++ $ openingsCount ; } if ( $ haystack [ $ c ] === '/' and $ haystack [ $ c - 1 ] === '*' ) { ++ $ closingsCount ; } } if ( $ openingsCount !== $ closingsCount ) { return true ; } return false ; }
Detect is character at specified position is inside of a comment
6,168
protected function backup ( ) { $ from = $ this -> configFile ; $ pathinfo = pathinfo ( $ from ) ; $ to = $ pathinfo [ 'dirname' ] . DIRECTORY_SEPARATOR . $ pathinfo [ 'filename' ] . '.bak.php' ; $ this -> file -> copy ( $ from , $ to ) ; }
Backup config file
6,169
public function addAlias ( $ alias , $ facade ) { if ( $ facadeCurrent = array_get ( $ this -> getAliases ( ) , $ alias ) ) { if ( $ facadeCurrent === $ facade ) { return ; } $ this -> commentOut ( $ alias , 'aliases' ) ; } $ quote = $ this -> getQuoteType ( 'aliases' ) ; $ separator = $ this -> getArrayItemsSeparator ( 'aliases' ) ; $ anchor = $ this -> getInsertPoint ( 'aliases' ) ; $ insert = $ separator . $ quote . $ alias . $ quote . ' => ' . $ quote . $ facade . $ quote . ',' ; $ this -> write ( $ insert , $ anchor ) ; }
Add specified facade .
6,170
public function getDateHumanReadable ( $ column , $ format = 'd-m-Y H:i:s' , $ maxDays = 3 ) { $ date = $ this -> { $ column } ; if ( ! $ date instanceof Carbon ) { return $ column ; } $ daysDifference = $ date -> diffInDays ( ) ; if ( $ daysDifference > $ maxDays ) { return $ date -> format ( $ format ) ; } return $ date -> diffForHumans ( ) ; }
Convert date to human - readable E . g . 2 hours ago .
6,171
public function prepareFor ( ContentStreamAware $ entity , $ type , $ locale , $ revision = 'default' , $ save = TRUE ) { try { $ contentStream = $ entity -> getContentStream ( ) -> locale ( $ locale ) -> type ( $ type ) -> revision ( $ revision ) -> one ( ) ; } catch ( NoContentStreamsFoundException $ e ) { $ contentStream = $ this -> createEmptyEntity ( $ revision ) -> setLocale ( $ locale ) -> setRevision ( $ revision ) -> setType ( $ type ) ; $ entity -> addContentStream ( $ contentStream ) ; if ( $ save ) { $ this -> repository -> save ( $ contentStream ) ; $ this -> repository -> persist ( $ entity ) ; } } return $ contentStream ; }
Adds or returns a new ContentStream for the entity
6,172
public function isSame ( Collection $ collection , $ compareFunction ) { if ( count ( $ this ) !== count ( $ collection ) ) return FALSE ; $ compareFunction = $ this -> compileCompareFunction ( $ compareFunction ) ; foreach ( $ this as $ key => $ element ) { if ( ( $ otherElement = $ collection -> get ( $ key ) ) === NULL ) { return FALSE ; } if ( $ compareFunction ( $ element , $ otherElement ) !== 0 ) { return FALSE ; } } return TRUE ; }
Vergleicht die Collections auf identische Inhalte
6,173
public function isEqual ( Collection $ collection , $ compareFunction ) { if ( count ( $ this ) !== count ( $ collection ) ) return FALSE ; if ( count ( $ this -> insertDiff ( $ collection , $ compareFunction ) ) > 0 ) return FALSE ; if ( count ( $ this -> deleteDiff ( $ collection , $ compareFunction ) ) > 0 ) return FALSE ; return TRUE ; }
Vergleicht die Inhalte zweier Collections
6,174
public function convert ( \ stdClass $ table , $ excelFile = NULL , $ removeEmpty = TRUE ) { $ excelFile = $ excelFile ? : $ this -> v -> validateUploadedFile ( 'excelFile' ) ; $ reader = PHPExcel_IOFactory :: createReaderForFile ( ( string ) $ excelFile ) ; $ excel = $ reader -> load ( ( string ) $ excelFile ) ; $ sheet = $ excel -> getSheet ( 0 ) ; $ columns = isset ( $ table -> columns ) ? ( array ) $ table -> columns : array ( ) ; $ nullValue = '' ; $ data = array ( ) ; $ mCell = 0 ; foreach ( $ sheet -> getRowIterator ( ) as $ wsRow ) { $ row = array ( ) ; $ empty = TRUE ; foreach ( $ wsRow -> getCellIterator ( ) as $ cell ) { $ cellIndex = h :: getColumnIndex ( $ cell -> getColumn ( ) ) ; $ mCell = max ( $ mCell , $ cellIndex + 1 ) ; $ row [ $ cellIndex ] = $ value = $ this -> convertValue ( $ cell -> getValue ( ) , isset ( $ columns [ $ cellIndex ] ) && isset ( $ columns [ $ cellIndex ] -> type ) ? $ columns [ $ cellIndex ] -> type : NULL ) ; if ( $ value != '' ) { $ empty = FALSE ; } } if ( ! $ removeEmpty || ! $ empty ) { ksort ( $ row ) ; $ data [ ] = array_replace ( array_fill ( 0 , $ mCell , $ nullValue ) , $ row ) ; } } return new ServiceResponse ( Service :: OK , $ data , ServiceResponse :: JSON_UPLOAD_RESPONSE ) ; }
Konvertiert ein Excel in einen Array
6,175
private function cleanData ( ) { foreach ( $ this -> data as & $ item ) { $ item = is_array ( $ item ) ? [ ] : null ; } unset ( $ item ) ; }
Clean data .
6,176
public function gatherFileData ( ) { $ files = get_included_files ( ) ; $ data = array ( ) ; foreach ( $ files as $ file ) { array_push ( $ data , array ( 'name' => $ file , 'size' => filesize ( $ file ) ) ) ; } return $ data ; }
Get data about files loaded for the application to current point
6,177
public function gatherQueryData ( $ dbConnection = null ) { if ( is_null ( $ dbConnection ) ) { return array ( ) ; } if ( empty ( $ this -> profiledQueries ) && property_exists ( $ dbConnection , 'queries' ) ) { $ this -> setProfiledQueries ( $ dbConnection -> queries ) ; } $ data = array ( ) ; foreach ( $ this -> profiledQueries as $ query ) { array_push ( $ data , array ( 'sql' => $ query [ 'sql' ] , 'explain' => $ this -> explainQuery ( $ dbConnection , $ query [ 'sql' ] , $ query [ 'parameters' ] ) , 'time' => $ query [ 'time' ] ) ) ; } return $ data ; }
Get data about sql usage of the application
6,178
protected function explainQuery ( $ dbConnection , $ query , $ parameters = array ( ) ) { $ driver = $ dbConnection -> getAttribute ( \ PDO :: ATTR_DRIVER_NAME ) ; $ query = $ this -> getExplainQuery ( $ query , $ driver ) ; $ statement = $ dbConnection -> prepare ( $ query ) ; if ( $ statement === false ) { throw new Exception ( 'Invalid query passed to explainQuery method' ) ; } $ statement -> execute ( $ parameters ) ; $ result = $ statement -> fetch ( \ PDO :: FETCH_ASSOC ) ; if ( $ result === false ) { throw new Exception ( 'Query could not be explained with given parameters' ) ; } return $ result ; }
Attempts to explain a query
6,179
public function gatherSpeedData ( ) { $ elapsedTime = microtime ( true ) - $ this -> startTime ; $ elapsedTime = round ( $ elapsedTime , 3 ) ; $ allowedTime = ini_get ( 'max_execution_time' ) ; return array ( 'elapsed' => $ elapsedTime , 'allowed' => $ allowedTime ) ; }
Get data about speed of the application
6,180
public function display ( $ dbConnection = null ) { if ( ! isset ( $ this -> display ) ) { throw new Exception ( 'Display object has not been injected into Profiler' ) ; } if ( ! isset ( $ this -> console ) ) { throw new Exception ( 'Console object has not been injected into Profiler' ) ; } $ this -> display -> setStartTime ( $ this -> startTime ) ; $ this -> display -> setConsole ( $ this -> console ) ; $ this -> display -> setFileData ( $ this -> gatherFileData ( ) ) ; $ this -> display -> setMemoryData ( $ this -> gatherMemoryData ( ) ) ; $ this -> display -> setQueryData ( $ this -> gatherQueryData ( $ dbConnection ) ) ; $ this -> display -> setSpeedData ( $ this -> gatherSpeedData ( ) ) ; $ this -> display -> __invoke ( ) ; }
Triggers end display of the profiling data
6,181
public function getHeader ( $ header ) { $ header = ucwords ( strtolower ( $ header ) ) ; if ( ! is_string ( $ header ) || ! isset ( $ this -> headers [ $ header ] ) ) return null ; return $ this -> headers [ $ header ] ; }
Get a specific header as string or null if it is not set
6,182
public function getHeadersAsString ( $ status_line = true , $ br = "\n" ) { $ str = '' ; if ( $ status_line ) { $ str = "HTTP/{$this->version} {$this->code} {$this->message}{$br}" ; } foreach ( $ this -> headers as $ name => $ value ) { if ( is_string ( $ value ) ) $ str .= "{$name}: {$value}{$br}" ; elseif ( is_array ( $ value ) ) { foreach ( $ value as $ subval ) { $ str .= "{$name}: {$subval}{$br}" ; } } } return $ str ; }
Get all headers as string
6,183
public function trace ( $ add_self = false ) { if ( is_null ( $ this -> trace ) ) { $ this -> trace = array ( ) ; if ( $ add_self ) { $ this -> trace [ ] = new CCError_Trace ( array ( 'file' => $ this -> exception -> getFile ( ) , 'line' => $ this -> exception -> getLine ( ) , 'class' => $ this -> exception_name ( ) , ) ) ; } foreach ( $ this -> exception -> getTrace ( ) as $ trace ) { $ this -> trace [ ] = new CCError_Trace ( $ trace ) ; } } return $ this -> trace ; }
get the inspector trace
6,184
public function tables ( ) { $ tables = array ( ) ; foreach ( static :: $ info_callbacks as $ name => $ callback ) { $ tables [ $ name ] = call_user_func ( $ callback ) ; } return array_merge ( $ tables , array ( 'Server / request data' => $ _SERVER , 'Get parameters' => $ _GET , 'Post parameters' => $ _POST , 'Cookies' => $ _COOKIE , 'Files' => $ _FILES , ) ) ; }
returns all debug tables
6,185
public function get ( $ name , array $ params = array ( ) ) { if ( null === $ this -> serviceLocator ) { throw new DomainException ( 'No ServiceLocator defined, use `createServiceWithName` instead of `get`' ) ; } if ( self :: USE_SL_BEFORE_DI === $ this -> useServiceLocator && $ this -> serviceLocator -> has ( $ name ) ) { return $ this -> serviceLocator -> get ( $ name ) ; } try { return parent :: get ( $ name , $ params ) ; } catch ( ClassNotFoundException $ e ) { if ( self :: USE_SL_AFTER_DI === $ this -> useServiceLocator && $ this -> serviceLocator -> has ( $ name ) ) { return $ this -> serviceLocator -> get ( $ name ) ; } throw new Exception \ ServiceNotFoundException ( sprintf ( 'Service %s was not found in this DI instance' , $ name ) , null , $ e ) ; } }
Overrides Zend \ Di to allow the given serviceLocator s services to be reused by Di itself
6,186
function off ( string $ event , $ callback ) : bool { return $ this -> getEventEmitter ( ) -> off ( $ event , $ callback ) ; }
Unregister a callback
6,187
public function addEncryptionSelect ( $ column = [ ] ) { $ columnName = ( isset ( $ column [ 'alias' ] ) && ! empty ( $ column [ 'alias' ] ) ) ? $ column [ 'alias' ] : $ column [ 'column' ] ; $ this -> encryptionColumns [ $ columnName ] = $ column ; return $ this ; }
Add a new select encryption_column to the query .
6,188
public function setReorderCallback ( $ reorderCallback ) { $ hash = sha1 ( $ reorderCallback ) ; $ this -> properties [ 'reorderCallback' ] = $ hash ; $ this -> callbacks [ $ hash ] = $ reorderCallback ; return $ this ; }
Callback function which can be used to perform actions when the columns have been reordered .
6,189
public function purgeDeleted ( $ timeFrame ) { $ config = $ this -> allConfig ( ) ; return $ this -> getRepository ( ) -> deleteMany ( function ( Query $ query ) use ( $ timeFrame , $ config ) { if ( $ timeFrame ) { $ query -> where ( $ config [ 'deleteField' ] , '>=' , Time :: toUnix ( $ timeFrame ) ) ; } else if ( $ config [ 'useFlag' ] ) { $ query -> where ( $ config [ 'flagField' ] , true ) ; } else { $ query -> where ( $ config [ 'deleteField' ] , '!=' , null ) ; } } , [ 'before' => false , 'after' => false ] ) ; }
Purge all soft deleted records from the database . If a time frame is provided delete all records within that time frame . If no time frame is provided delete all records based on flag or timestamp being not null .
6,190
public function softDelete ( $ id ) { return $ this -> getRepository ( ) -> update ( $ id , [ $ this -> getConfig ( 'flagField' ) => true , $ this -> getConfig ( 'deleteField' ) => time ( ) ] , [ 'before' => false , 'after' => false ] ) ; }
Perform a soft delete by marking a record as deleted and updating a timestamp . Do not delete the actual record .
6,191
public function saveEntity ( $ identifier , FormData $ requestData , $ subResource = NULL ) { $ revision = $ this -> defaultRevision ; $ entity = $ this -> getEntity ( $ identifier ) ; if ( $ subResource !== NULL && array_key_exists ( $ subResource , $ this -> customActions ) ) { return $ this -> callCustomAction ( $ this -> customActions [ $ subResource ] , array ( $ entity , $ requestData , $ revision ) ) ; } return $ this -> updateEntityRevision ( $ entity , $ revision , $ requestData , $ subResource ) ; }
Saves the Entity default Revision
6,192
public function insertEntity ( FormData $ requestData , $ subResource = NULL ) { return $ this -> insertEntityRevision ( $ this -> defaultRevision , $ requestData , $ subResource ) ; }
Inserts a new Entity in default Revision
6,193
public function insertEntityRevision ( $ revision , FormData $ requestData , $ subResource = NULL ) { $ entity = $ this -> createEmptyEntity ( $ revision ) ; if ( $ subResource !== NULL && array_key_exists ( $ subResource , $ this -> customActions ) ) { return $ this -> callCustomAction ( $ this -> customActions [ $ subResource ] , array ( $ entity , $ requestData , $ revision ) ) ; } $ this -> updateEntityRevision ( $ entity , $ revision , $ requestData ) ; $ this -> setOpenTabMetadata ( $ entity ) ; return $ entity ; }
Inserts a new Entity in specific Revision
6,194
public function createEmptyEntity ( $ revision = NULL ) { $ c = $ this -> getEntityName ( ) ; try { $ gClass = new GClass ( $ c ) ; return $ gClass -> newInstance ( array ( ) , GClass :: WITHOUT_CONSTRUCTOR ) ; } catch ( \ ErrorException $ e ) { if ( mb_strpos ( $ e -> getMessage ( ) , 'Missing argument' ) !== FALSE ) { throw new \ Psc \ Exception ( sprintf ( "Kann kein leeres Entity '%s' mit leerem Constructor erstellen. createEmptyEntity() kann im Controller abgeleitet werden, um das Problem zu beheben" , $ c ) , 0 , $ e ) ; } else { throw $ e ; } } }
Erstellt ein leeres Entity
6,195
public function trans ( $ key , Array $ parameters = array ( ) , $ domain = NULL ) { if ( ! isset ( $ domain ) ) $ domain = 'project' ; return $ this -> translationContainer -> getTranslator ( ) -> trans ( $ key , $ parameters , $ domain ) ; }
public for usage in 5 . 3 in closures
6,196
protected function initPropertyTranslations ( $ domain = NULL ) { $ entityMeta = $ this -> getEntityMeta ( ) ; $ translator = $ this -> translationContainer -> getTranslator ( ) ; $ this -> on ( 'init.labeler' , function ( $ labeler ) use ( $ domain , $ entityMeta , $ translator ) { foreach ( $ entityMeta -> getSetMeta ( ) -> getKeys ( ) as $ propertyName ) { $ property = $ entityMeta -> getPropertyMeta ( $ propertyName ) ; $ labeler -> label ( $ property -> getName ( ) , $ translator -> trans ( sprintf ( 'entities.%s.%s' , $ entityMeta -> getEntityName ( ) , $ property -> getCanonicalName ( ) ) , array ( ) , $ domain ? : 'project' ) ) ; } } ) ; }
Loads translations keys for each property of the entity of the controller with labels
6,197
public static function createUsingFormat ( $ format ) { $ previous = null ; if ( 1 < func_num_args ( ) ) { $ args = array_slice ( func_get_args ( ) , 1 ) ; if ( end ( $ args ) instanceof \ Exception ) { $ previous = array_pop ( $ args ) ; } if ( $ args ) { $ format = vsprintf ( $ format , $ args ) ; } } return new static ( $ format , 0 , $ previous ) ; }
Creates a new exception using a formatted message .
6,198
public function listSubscribe ( $ listId , $ email , Array $ mergeVars = NULL , $ emailType = 'text' , $ doubleOptin = true , $ updateExisting = false , $ replaceInterests = true , $ sendWelcome = true ) { $ response = $ this -> dispatch ( __FUNCTION__ , array ( 'id' => $ listId , 'email_address' => $ email , 'email_type' => $ emailType ) ) ; if ( $ response -> getRaw ( ) === 'true' ) { return TRUE ; } else { throw Exception :: unknown ( $ response -> getRaw ( ) ) ; } }
Subscribe the provided email to a list . By default this sends a confirmation email - you will not see new members until the link contained in it is clicked!
6,199
public static function expr ( $ field , $ operator = null , $ value = null ) { return new Expr ( $ field , $ operator , $ value ) ; }
Instantiate a new database expression .