idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
26,600 | public static function str_utf8_mix_word_count ( $ str = "" ) { $ str = preg_replace ( self :: UTF8_SYMBOL_PATTERN , "" , $ str ) ; return self :: str_utf8_chinese_word_count ( $ str ) + str_word_count ( preg_replace ( self :: UTF8_CHINESE_PATTERN , "" , $ str ) ) ; } | count both chinese and english |
26,601 | public static function baseUri ( $ mode = null ) : string { switch ( $ mode ) { case Wechat :: MODE_DEV : self :: getInstance ( ) -> baseUri = 'https://api.mch.weixin.qq.com/sandboxnew/' ; break ; case Wechat :: MODE_HK : self :: getInstance ( ) -> baseUri = 'https://apihk.mch.weixin.qq.com/' ; break ; default : break ; } return self :: getInstance ( ) -> baseUri ; } | Wechat gateway . |
26,602 | private function triggerError ( $ message ) { $ pdo = $ this -> pdoSupplier -> getPDO ( ) ; $ mode = $ pdo -> getAttribute ( \ PDO :: ATTR_ERRMODE ) ; switch ( $ mode ) { case \ PDO :: ERRMODE_WARNING : trigger_error ( $ message , E_USER_ERROR ) ; break ; case \ PDO :: ERRMODE_EXCEPTION : throw new \ RuntimeException ( $ message ) ; break ; case \ PDO :: ERRMODE_SILENT : default : break ; } } | Honor the PDO ATTR_ERRMODE . |
26,603 | public function addExtension ( $ className ) { $ object = is_object ( $ className ) ? $ className : null ; $ className = is_object ( $ className ) ? get_class ( $ object ) : $ className ; $ this -> checkExtension ( $ className ) ; self :: $ extensions [ $ className ] = $ object ; return $ this ; } | Adds an extension to the template engine |
26,604 | private function applyExtensions ( TemplateEngineInterface $ engine ) { foreach ( static :: $ extensions as $ className => $ extension ) { $ ext = $ this -> getExtension ( $ className , $ extension ) ; if ( $ ext -> appliesTo ( $ engine ) ) { $ ext -> update ( $ engine ) ; } } return $ engine ; } | Apply defined extensions to the provided template engine |
26,605 | public static function fromXml ( \ DOMElement $ xml ) { $ static = new static ( ) ; $ static -> libraryItemMetadata = LibraryItemMetadata :: fromXml ( $ xml ) ; $ static -> pickupLocation = PickupLocation :: fromXml ( $ xml ) ; $ requestStartDate = $ xml -> getElementsByTagName ( 'requestDate' ) ; $ requestEndDate = $ xml -> getElementsByTagName ( 'endRequestDate' ) ; $ static -> requestDateRange = DateTimeRange :: fromXml ( $ requestStartDate , $ requestEndDate ) ; $ holdStartDate = $ xml -> getElementsByTagName ( 'holdDate' ) ; $ holdEndDate = $ xml -> getElementsByTagName ( 'endHoldDate' ) ; $ static -> holdDateRange = DateTimeRange :: fromXml ( $ holdStartDate , $ holdEndDate ) ; $ cancelable = $ xml -> getElementsByTagName ( 'cancelable' ) ; $ static -> cancelable = BoolLiteral :: fromXml ( $ cancelable ) ; $ stringLiterals = array ( 'requestNumber' => $ xml -> getElementsByTagName ( 'requestNumber' ) , 'sequence' => $ xml -> getElementsByTagName ( 'sequence' ) , 'queuePosition' => $ xml -> getElementsByTagName ( 'queuePosition' ) , 'itemSequence' => $ xml -> getElementsByTagName ( 'itemSequence' ) , 'status' => $ xml -> getElementsByTagName ( 'status' ) , ) ; foreach ( $ stringLiterals as $ propertyName => $ xmlTag ) { $ static -> $ propertyName = StringLiteral :: fromXml ( $ xmlTag ) ; } return $ static ; } | Builds a Hold object from XML . |
26,606 | protected function truncate ( $ string , $ length = 30 , $ separator = '...' ) { if ( mb_strlen ( $ string ) > $ length ) { return rtrim ( mb_substr ( $ string , 0 , $ length ) ) . $ separator ; } return $ string ; } | Truncate string . |
26,607 | private function bootModules ( ) { foreach ( $ this -> app [ 'modules' ] -> enabled ( ) as $ module ) { $ this -> registerViewNamespace ( $ module ) ; $ this -> registerLanguageNamespace ( $ module ) ; $ this -> registerConfigNamespace ( $ module ) ; } } | Register the modules aliases . |
26,608 | protected function registerViewNamespace ( Module $ module ) { $ this -> app [ 'view' ] -> addNamespace ( $ module -> getName ( ) , $ module -> getPath ( ) . '/Resources/views' ) ; } | Register the view namespaces for the modules . |
26,609 | protected function registerLanguageNamespace ( Module $ module ) { $ moduleName = $ module -> getName ( ) ; $ langPath = base_path ( "resources/lang/modules/$moduleName" ) ; if ( is_dir ( $ langPath ) ) { $ this -> loadTranslationsFrom ( $ langPath , $ moduleName ) ; $ this -> app [ 'localization.js-generator' ] -> addSourcePath ( $ langPath , $ moduleName ) ; } else { $ this -> loadTranslationsFrom ( $ module -> getPath ( ) . '/Resources/lang' , $ moduleName ) ; $ this -> app [ 'localization.js-generator' ] -> addSourcePath ( $ module -> getPath ( ) . '/Resources/lang' , $ moduleName ) ; } } | Register the language namespaces for the modules . |
26,610 | public static function exception ( $ title , PhpException $ e ) { $ exceptionMessage = ( string ) $ e -> getMessage ( ) ; $ content = ( string ) $ title . PHP_EOL . 'Exception of type \'' . get_class ( $ e ) . '\': ' . $ exceptionMessage ; self :: $ logger -> exception ( new PhpException ( $ content , null , $ e ) ) ; return true ; } | Save an exception as an error in the log file . |
26,611 | public static function err ( $ message , array $ extras = [ ] ) { if ( self :: $ logger ) { self :: $ logger -> err ( $ message , $ extras ) ; } } | Log an error message for external consumption . |
26,612 | public static function debug ( $ message , array $ extras = [ ] ) { if ( self :: $ logger ) { self :: $ logger -> debug ( $ message , $ extras ) ; } } | Log a debug message for internal use . |
26,613 | public static function info ( $ message , array $ extras = [ ] ) { if ( self :: $ logger ) { self :: $ logger -> info ( $ message , $ extras ) ; } } | Log an info message for external consumption . |
26,614 | public static function notice ( $ message , array $ extras = [ ] ) { if ( self :: $ logger ) { self :: $ logger -> notice ( $ message , $ extras ) ; } } | Log a notice message for external consumption . |
26,615 | public static function warn ( $ message , array $ extras = [ ] ) { if ( self :: $ logger ) { self :: $ logger -> warn ( $ message , $ extras ) ; } } | Log a warning message for external consumption . |
26,616 | public static function crit ( $ message , array $ extras = [ ] ) { if ( self :: $ logger ) { self :: $ logger -> crit ( $ message , $ extras ) ; } } | Log a critical message for external consumption . |
26,617 | public static function alert ( $ message , array $ extras = [ ] ) { if ( self :: $ logger ) { self :: $ logger -> alert ( $ message , $ extras ) ; } } | Log an alert message for external consumption . |
26,618 | public static function emerg ( $ message , array $ extras = [ ] ) { if ( self :: $ logger ) { self :: $ logger -> emerg ( $ message , $ extras ) ; } } | Log an emergency message for external consumption . |
26,619 | public function delete ( $ key ) { if ( ! $ this -> has ( $ key ) ) return null ; $ value = $ this -> items [ $ key ] ; unset ( $ this -> items [ $ key ] ) ; return $ value ; } | Unset item from collection via index and return value |
26,620 | protected function loadSession ( array & $ session = null ) { if ( null === $ session ) { $ session = & $ _SESSION ; } $ key = $ this -> getAttributes ( ) -> getName ( ) ; $ session [ $ key ] = isset ( $ session [ $ key ] ) ? $ session [ $ key ] : array ( ) ; $ this -> getAttributes ( ) -> initialize ( $ session [ $ key ] ) ; $ this -> started = true ; $ this -> closed = false ; } | Load the session with attributes |
26,621 | public function exists ( array $ criteria ) : bool { $ query = $ this -> prepareQuery ( $ criteria ) ; $ query -> setSize ( 0 ) ; $ query -> setParam ( 'terminate_after' , 1 ) ; return $ this -> collection -> search ( $ query ) -> count ( ) > 0 ; } | Checks whether a document matching criteria exists in collection . |
26,622 | public function insert ( $ document ) : ? PostInsertId { $ class = $ this -> dm -> getClassMetadata ( get_class ( $ document ) ) ; $ idGenerator = $ this -> dm -> getUnitOfWork ( ) -> getIdGenerator ( $ class -> idGeneratorType ) ; $ postIdGenerator = $ idGenerator -> isPostInsertGenerator ( ) ; $ id = $ postIdGenerator ? null : $ class -> getSingleIdentifier ( $ document ) ; $ body = $ this -> prepareUpdateData ( $ document ) [ 'body' ] ; $ response = $ this -> collection -> create ( $ id , $ body ) ; $ data = $ response -> getData ( ) ; foreach ( $ class -> attributesMetadata as $ field ) { if ( ! $ field instanceof FieldMetadata ) { continue ; } if ( $ field -> indexName ) { $ field -> setValue ( $ document , $ data [ '_index' ] ?? null ) ; } if ( $ field -> typeName ) { $ field -> setValue ( $ document , $ data [ '_type' ] ?? null ) ; } } $ postInsertId = null ; if ( $ postIdGenerator ) { $ postInsertId = new PostInsertId ( $ document , $ this -> collection -> getLastInsertedId ( ) ) ; } return $ postInsertId ; } | Insert a document in the collection . |
26,623 | public function update ( $ document ) : void { $ class = $ this -> dm -> getClassMetadata ( get_class ( $ document ) ) ; $ data = $ this -> prepareUpdateData ( $ document ) ; $ id = $ class -> getSingleIdentifier ( $ document ) ; $ this -> collection -> update ( ( string ) $ id , $ data [ 'body' ] , $ data [ 'script' ] ) ; } | Updates a managed document . |
26,624 | public function delete ( $ document ) : void { $ class = $ this -> dm -> getClassMetadata ( get_class ( $ document ) ) ; $ id = $ class -> getSingleIdentifier ( $ document ) ; $ this -> collection -> delete ( ( string ) $ id ) ; } | Deletes a managed document . |
26,625 | public function readInterface ( $ object = null ) { $ properties = new Map ( ) ; if ( $ this -> class -> getConstructor ( ) ) { foreach ( $ this -> class -> getConstructor ( ) -> getParameters ( ) as $ parameter ) { $ this -> accumulate ( $ properties , new property \ ConstructorProperty ( $ this -> factory , $ this -> class -> getConstructor ( ) , $ parameter ) ) ; } } $ declaredProperties = array ( ) ; foreach ( $ this -> class -> getProperties ( \ ReflectionProperty :: IS_PUBLIC ) as $ property ) { if ( ! $ property -> isStatic ( ) ) { $ declaredProperties [ ] = $ property -> name ; $ this -> accumulate ( $ properties , new property \ InstanceVariableProperty ( $ this -> factory , $ property ) ) ; } } if ( is_object ( $ object ) ) { foreach ( $ object as $ name => $ value ) { if ( ! in_array ( $ name , $ declaredProperties ) ) { $ this -> accumulate ( $ properties , new property \ DynamicProperty ( $ this -> factory , new \ ReflectionClass ( $ object ) , $ name ) ) ; } } } foreach ( $ this -> class -> getMethods ( \ ReflectionMethod :: IS_PUBLIC ) as $ method ) { if ( property \ AccessorProperty :: isAccessor ( $ method ) && ! $ method -> isStatic ( ) ) { $ this -> accumulate ( $ properties , new property \ AccessorProperty ( $ this -> factory , $ method ) ) ; } } return $ properties ; } | Derives properties from constructor public instance variables getters and setters . |
26,626 | public function connect ( ) { $ link = ssh2_connect ( $ this -> _config [ 'host' ] , $ this -> _config [ 'port' ] ) ; if ( ! $ link ) { throw new \ Exception ( 'Unable to connect to ' . $ host . ' on port ' . $ port ) ; } else { $ this -> _conn_link = $ link ; if ( ! is_null ( $ this -> _config [ 'host_fingerprint' ] ) ) { $ verify = $ this -> verify_host_fingerprint ( ) ; if ( ! $ verify ) { throw new \ Exception ( 'Unable to verify host fingerprint' ) ; } } } if ( $ this -> _config [ 'authentication_method' ] == 'KEY' ) { $ this -> _connected = $ this -> login_key ( ) ; } else { $ this -> _connected = $ this -> login_password ( ) ; } $ this -> _connected && $ this -> _sftp = ssh2_sftp ( $ link ) ; } | Connect to host |
26,627 | protected function verify_host_fingerprint ( ) { $ fingerprint = ssh2_fingerprint ( $ this -> _conn_link ) ; if ( $ this -> _config [ 'host_fingerprint' ] === $ fingerprint ) { return TRUE ; } else { return FALSE ; } } | Verify host fingerprint |
26,628 | public function login_key ( ) { return ssh2_auth_pubkey_file ( $ this -> _conn_link , $ this -> _config [ 'pub_key' ] , $ this -> _config [ 'private_key' ] , $ this -> _config [ 'passphrase' ] ) ; } | Login using a key |
26,629 | public function exec ( $ command , $ pty = NULL , $ env = array ( ) , $ width = 80 , $ height = 25 , $ width_height_type = SSH2_TERM_UNIT_CHARS ) { return ssh2_exec ( $ this -> _conn_link , $ command ) ; } | Exec a command |
26,630 | public function send_file ( $ local_filepath , $ remote_filepath , $ create_mode = 0644 ) { $ local_filepath = $ this -> format_path ( $ local_filepath ) ; $ remote_filepath = $ this -> format_path ( $ remote_filepath ) ; return ssh2_scp_send ( $ this -> _conn_link , $ local_filepath , $ remote_filepath , $ create_mode ) ; } | Sends a file to the remote server using scp |
26,631 | public function receive_file ( $ remote_filepath , $ local_filepath ) { $ local_filepath = $ this -> format_path ( $ local_filepath ) ; $ remote_filepath = $ this -> format_path ( $ remote_filepath ) ; return ssh2_scp_recv ( $ this -> _conn_link , $ remote_filepath , $ local_filepath ) ; } | Requests a file from the remote server using SCP |
26,632 | public function disconnect ( ) { $ this -> exec ( 'echo "EXITING" && exit;' ) ; $ this -> _conn_link = NULL ; $ this -> _connected = FALSE ; $ this -> _sftp = NULL ; } | Disconnects from the connected server |
26,633 | private static function convertFromMongo ( array $ data ) { if ( isset ( $ data [ '_id' ] ) ) { $ data [ 'id' ] = $ data [ '_id' ] ; unset ( $ data [ '_id' ] ) ; } foreach ( $ data as $ name => & $ value ) { if ( is_array ( $ value ) ) { $ value = self :: convertFromMongo ( $ value ) ; } elseif ( is_object ( $ value ) ) { switch ( get_class ( $ value ) ) { case 'MongoId' : $ value = $ value -> __toString ( ) ; break ; case 'MongoDate' : $ value = new \ DateTime ( '@' . $ value -> sec ) ; break ; } } } return $ data ; } | Convert the various Mongo - based objects into PHP standard types and apply other conversions to standardise Mongo s idiosyncrasies . |
26,634 | private static function convertToMongo ( array & $ data ) { if ( isset ( $ data [ 'id' ] ) ) { $ data [ '_id' ] = $ data [ 'id' ] ; unset ( $ data [ 'id' ] ) ; } foreach ( $ data as $ name => & $ value ) { if ( is_string ( $ value ) ) { if ( mb_detect_encoding ( $ value ) != 'UTF-8' ) { $ value = mb_convert_encoding ( $ value , 'UTF-8' ) ; } } elseif ( $ value instanceof Entity ) { $ value = $ value -> getFieldsData ( ) ; } elseif ( is_array ( $ value ) ) { self :: convertToMongo ( $ value ) ; } } } | Convert entity data so that it better fits Mongo s idiosyncrasies . |
26,635 | public function isOk ( $ caller = null ) { foreach ( $ this -> conditions as $ condition ) { if ( ! $ condition -> isOk ( $ caller ) ) { return false ; } } return true ; } | Returns true if the condition is met false otherwise . |
26,636 | public function withStatus ( $ code , $ reason = '' ) { $ code = Validator :: checkCode ( $ code ) ; if ( ! is_string ( $ reason ) && ! method_exists ( $ reason , '__toString' ) ) { throw new InvalidArgumentException ( 'ReasonPhrase must be a string' ) ; } $ clone = clone $ this ; $ clone -> code = $ code ; if ( $ reason === '' ) { $ reason = Validator :: getCodeMessage ( $ code ) ; } if ( $ reason === '' ) { throw new InvalidArgumentException ( 'ReasonPhrase must be supplied for this code' ) ; } $ clone -> phrase = $ reason ; return $ clone ; } | Return an instance with the specified status code and optionally reason phrase |
26,637 | public function table ( stdClass $ variable ) { ( new Table ( ) ) -> render ( $ this -> pdo , $ this -> info , $ variable , $ this -> output ) ; } | - Create table and insert rows |
26,638 | protected function getVariables ( ) { $ reflection = new ReflectionClass ( $ this ) ; foreach ( $ reflection -> getProperties ( ReflectionProperty :: IS_PROTECTED | ReflectionProperty :: IS_PRIVATE | ReflectionProperty :: IS_STATIC ) as $ property ) { $ ignore [ ] = $ property -> name ; } $ values = [ ] ; foreach ( $ this as $ prop => $ value ) { if ( ! in_array ( $ prop , $ ignore ) ) { if ( is_object ( $ value ) ) { if ( method_exists ( $ value , 'jsonSerialize' ) ) { $ value = $ value -> jsonSerialize ( ) ; } elseif ( method_exists ( $ value , 'getArrayCopy' ) ) { $ value = $ value -> getArrayCopy ( ) ; } } $ values [ $ prop ] = $ value ; } } return $ values ; } | Internal method to get all template variables i . e . the public properties on the view class . |
26,639 | public function execute ( Framework $ framework , WebRequest $ request , Response $ response ) { $ this -> setTitle ( $ this -> translate ( 'Profile - Change password' , '\\Zepi\\Web\\AccessControl' ) ) ; $ changePasswordForm = $ this -> createForm ( $ framework , $ request , $ response ) ; $ changePasswordForm -> processFormData ( $ request , $ response ) ; $ result = false ; $ errors = array ( ) ; if ( $ changePasswordForm -> isSubmitted ( ) ) { $ errors = $ changePasswordForm -> validateFormData ( $ framework ) ; if ( count ( $ errors ) === 0 ) { $ result = $ this -> changePassword ( $ changePasswordForm , $ framework , $ request , $ response ) ; } } $ errorBox = $ changePasswordForm -> getPart ( 'login-errors' ) ; $ errorBox -> updateErrorBox ( $ changePasswordForm , $ result , $ errors ) ; if ( ! $ changePasswordForm -> isSubmitted ( ) || $ errorBox -> hasErrors ( ) ) { $ renderedOutput = $ this -> render ( '\\Zepi\\Web\\AccessControl\\Templates\\ProfileChangePasswordForm' , array ( 'result' => $ result , 'errors' => $ errors , 'form' => $ changePasswordForm , 'layoutRenderer' => $ this -> getLayoutRenderer ( ) ) ) ; $ response -> setOutput ( $ renderedOutput ) ; } else { $ response -> setOutput ( $ this -> render ( '\\Zepi\\Web\\AccessControl\\Templates\\ProfileChangePasswordFinished' ) ) ; } } | Displays the change password site for the profile . |
26,640 | protected function createForm ( Framework $ framework , WebRequest $ request , Response $ response ) { $ form = new Form ( 'change-password' , $ request -> getFullRoute ( 'profile/change-password' ) , 'post' ) ; $ errorBox = new ErrorBox ( 'login-errors' , 1 ) ; $ form -> addPart ( $ errorBox ) ; $ group = new Group ( 'change-password' , $ this -> translate ( 'Please insert your old and your new password' , '\\Zepi\\Web\\AccessControl' ) , array ( new Password ( 'old-password' , $ this -> translate ( 'Old password' , '\\Zepi\\Web\\AccessControl' ) , true ) , new Password ( 'new-password' , $ this -> translate ( 'New password' , '\\Zepi\\Web\\AccessControl' ) , true ) , new Password ( 'new-password-confirmed' , $ this -> translate ( 'Confirm new password' , '\\Zepi\\Web\\AccessControl' ) , true ) , ) ) ; $ form -> addPart ( $ group ) ; $ buttonGroup = new ButtonGroup ( 'buttons' , array ( new Submit ( 'submit' , $ this -> translate ( 'Change password' , '\\Zepi\\Web\\AccessControl' ) ) ) , 100 ) ; $ form -> addPart ( $ buttonGroup ) ; return $ form ; } | Returns the Form object for the change password form |
26,641 | public static function isFunctionEnabled ( $ function , $ extension = null ) { return ( null === $ extension || extension_loaded ( $ extension ) ) && ! static :: isFunctionBlacklistedInPhpIni ( $ function ) && ! static :: isFunctionBlacklistedInSuhosin ( $ function ) && static :: isFunctionDefined ( $ function ) ; } | Check if function is defined . |
26,642 | public static function isFunctionBlacklistedInSuhosin ( $ function ) { if ( ! extension_loaded ( 'suhosin' ) ) { return false ; } if ( ! isset ( self :: $ blackListSuhosin ) ) { self :: $ blackListSuhosin = static :: prepareList ( ini_get ( 'suhosin.executor.func.blacklist' ) ) ; } return static :: isFunctionsMentionedInList ( $ function , self :: $ blackListSuhosin ) ; } | Check if function is blacklisted in Suhosin . |
26,643 | public static function isFunctionBlacklistedInPhpIni ( $ function ) { if ( ! isset ( self :: $ blackListPhpIni ) ) { self :: $ blackListPhpIni = static :: prepareList ( ini_get ( 'disable_functions' ) ) ; } return static :: isFunctionsMentionedInList ( $ function , self :: $ blackListPhpIni ) ; } | Check if method is blacklisted in Suhosin . |
26,644 | public static function inProperty ( string $ name , DeserializesCollections $ collection , ProducesProxies $ proxyBuilder ) : ExposesDataKey { return new self ( $ name , $ name , $ collection , $ proxyBuilder ) ; } | Creates a new lazily loaded has - many mapping . |
26,645 | public static function inPropertyWithDifferentKey ( string $ name , string $ key , DeserializesCollections $ collection , ProducesProxies $ proxyBuilder ) : ExposesDataKey { return new self ( $ name , $ key , $ collection , $ proxyBuilder ) ; } | Creates a new lazily loading has - many mapping using the data from a specific key . |
26,646 | private function makeSomeProxies ( int $ amount , ? object $ owner ) : array { $ proxies = [ ] ; for ( $ i = 0 ; $ i < $ amount ; ++ $ i ) { $ proxies [ ] = $ this -> proxyBuilder -> createFor ( $ owner , $ this -> name ( ) , $ i ) ; } return $ proxies ; } | Produces the proxies for in the collection . |
26,647 | private function sanitizeRoundsOfAiming ( $ roundsOfAiming ) : int { try { $ roundsOfAiming = ToInteger :: toPositiveInteger ( $ roundsOfAiming ) ; if ( $ roundsOfAiming > 3 ) { return 3 ; } return $ roundsOfAiming ; } catch ( \ Granam \ Integer \ Tools \ Exceptions \ Exception $ integerException ) { throw new Exceptions \ InvalidFormatOfRoundsOfAiming ( $ integerException -> getMessage ( ) ) ; } } | Aiming gives bonus up to three rounds of aim any addition is thrown away . |
26,648 | public function getAttackNumberModifier ( ) : int { $ attackNumber = 0 ; foreach ( $ this -> combatActionCodes as $ combatActionCode ) { if ( $ combatActionCode -> getValue ( ) === MeleeCombatActionCode :: HEADLESS_ATTACK ) { $ attackNumber += 2 ; } if ( $ combatActionCode -> getValue ( ) === MeleeCombatActionCode :: PRESSURE ) { $ attackNumber += 2 ; } if ( $ combatActionCode -> getValue ( ) === RangedCombatActionCode :: AIMED_SHOT ) { $ attackNumber += $ this -> finishedRoundsOfAiming ; } if ( $ combatActionCode -> getValue ( ) === CombatActionCode :: PUT_OUT_EASILY_ACCESSIBLE_ITEM ) { $ attackNumber += 2 ; } if ( $ combatActionCode -> getValue ( ) === CombatActionCode :: PUT_OUT_HARDLY_ACCESSIBLE_ITEM ) { $ attackNumber += 2 ; } if ( $ combatActionCode -> getValue ( ) === CombatActionCode :: LAYING ) { $ attackNumber -= 4 ; } if ( $ combatActionCode -> getValue ( ) === CombatActionCode :: SITTING_OR_ON_KNEELS ) { $ attackNumber -= 2 ; } if ( $ combatActionCode -> getValue ( ) === CombatActionCode :: BLINDFOLD_FIGHT ) { $ attackNumber -= 6 ; } if ( $ combatActionCode -> getValue ( ) === CombatActionCode :: FIGHT_IN_REDUCED_VISIBILITY ) { $ attackNumber -= 1 ; } } return $ attackNumber ; } | Note about AIMED SHOT you have to provide rounds of aim to get expected attack number . Maximum counted is + 3 more if truncated . |
26,649 | public function getDefenseNumberModifierAgainstFasterOpponent ( ) : int { $ defenseNumberModifier = $ this -> getDefenseNumberModifier ( ) ; foreach ( $ this -> combatActionCodes as $ combatActionCode ) { if ( $ combatActionCode -> getValue ( ) === CombatActionCode :: RUN ) { $ defenseNumberModifier -= 4 ; } if ( $ combatActionCode -> getValue ( ) === CombatActionCode :: PUT_OUT_HARDLY_ACCESSIBLE_ITEM ) { $ defenseNumberModifier -= 4 ; } } return $ defenseNumberModifier ; } | Against those opponents acting faster then you you can have significantly lower defense because they catch you unprepared . |
26,650 | public function getSpeedModifier ( ) : int { $ speedBonus = 0 ; foreach ( $ this -> combatActionCodes as $ combatActionCode ) { if ( $ combatActionCode -> getValue ( ) === CombatActionCode :: MOVE ) { $ speedBonus += 8 ; } if ( $ combatActionCode -> getValue ( ) === CombatActionCode :: RUN ) { $ speedBonus += 22 ; } } return $ speedBonus ; } | In case of MOVE or RUN there is significant speed increment . |
26,651 | public final function setLogger ( ? LoggerInterface $ logger ) { $ this -> _options [ 'logger' ] = null === $ logger ? new NullLogger ( ) : $ logger ; unset ( $ this -> _options [ 'data' ] ) ; return $ this ; } | Sets a new logger or null if no logger should be used . |
26,652 | public function setOption ( string $ name , $ value ) { $ this -> _options [ $ name ] = $ value ; unset ( $ this -> _options [ 'data' ] ) ; return $ this ; } | Sets a options value . |
26,653 | public function addFields ( array $ fields ) { foreach ( $ fields as $ field ) { $ name = $ field -> getName ( ) ; $ addFields [ $ name ] = $ field ; } $ keysString = "" ; $ fieldStrings = array ( ) ; foreach ( $ addFields as $ fieldName => $ field ) { $ fieldStrings [ ] = $ field -> getFieldString ( ) ; if ( $ field -> isPrimaryKey ( ) ) { $ errMsg = 'Do not set field to be primary key when adding fields. ' . 'Instead, use the changePrimaryKey method' ; throw new \ Exception ( $ errMsg ) ; } elseif ( $ field -> isKey ( ) ) { if ( $ keysString !== "" ) { $ keysString .= ", " ; } if ( $ field -> isUnique ( ) ) { $ keysString .= "UNIQUE " ; } $ keysString .= "KEY (`" . $ fieldName . "`) " ; } } $ fieldsString = implode ( ", " , $ fieldStrings ) ; $ fieldsString .= $ keysString ; $ query = "ALTER TABLE " . "`" . $ this -> m_name . "` " . "ADD " . "(" . $ fieldsString . ") " ; $ result = $ this -> m_mysqliConn -> query ( $ query ) ; if ( $ result !== TRUE ) { throw new \ Exception ( 'Error creating table with query: ' . $ query ) ; } } | Adds the specified fields to this table . |
26,654 | public function removeKey ( $ key ) { if ( is_array ( $ key ) ) { $ keyString = "(" . implode ( ',' , $ key ) . ")" ; } else { $ keyString = "`" . $ key . "`" ; } $ query = "ALTER TABLE " . '`' . $ this -> m_name . '` ' . "DROP INDEX " . $ keyString ; $ result = $ this -> m_mysqliConn -> query ( $ query ) ; return $ result ; } | Remove a key from the database . This does not remove the field itself . |
26,655 | public function changeEngine ( $ engine ) { $ allowed_engines = array ( self :: ENGINE_INNODB , self :: ENGINE_MYISAM ) ; if ( ! in_array ( $ engine , $ allowed_engines ) ) { throw new \ Exception ( 'Unrecognized engine: ' . $ engine ) ; } $ query = "ALTER TABLE `" . $ this -> m_name . "` " . "ENGINE=" . $ engine ; $ result = $ this -> m_mysqliConn -> query ( $ query ) ; return $ result ; } | Change the tables engine to something else . Please make use of this classes constants when providing the engine parameter . |
26,656 | public function setOption ( $ name , $ value ) { @ trigger_error ( sprintf ( 'The %s() method is deprecated since version 3.3 and will be removed in 4.0.' , __METHOD__ ) , E_USER_DEPRECATED ) ; $ this -> options [ $ name ] = $ value ; return $ this ; } | Adds a proc_open option . |
26,657 | public static function sortByKey ( $ data , $ sortKey , $ sort_flags = SORT_ASC ) { if ( empty ( $ data ) or empty ( $ sortKey ) ) { return $ data ; } $ ordered = [ ] ; $ i = 0 ; foreach ( $ data as $ key => $ value ) { ++ $ i ; $ ordered [ $ value [ $ sortKey ] . '-' . $ i ] = $ value ; } switch ( $ sort_flags ) { case SORT_ASC : ksort ( $ ordered , SORT_NUMERIC ) ; break ; case SORT_DESC : krsort ( $ ordered , SORT_NUMERIC ) ; break ; } return array_values ( $ ordered ) ; } | Sort the array by an object s key value . |
26,658 | public static function getWhere ( $ array , $ key , $ search , $ default = null ) { foreach ( $ array as $ item ) { if ( isset ( $ item [ $ key ] ) && $ item [ $ key ] == $ search ) { return $ item ; } } return $ default ; } | Get an object in the array where its key is the same as the search value . |
26,659 | public static function seedShuffle ( & $ array , $ seed ) { @ mt_srand ( $ seed ) ; for ( $ i = count ( $ array ) - 1 ; $ i > 0 ; -- $ i ) { $ j = @ mt_rand ( 0 , $ i ) ; $ tmp = $ array [ $ i ] ; $ array [ $ i ] = $ array [ $ j ] ; $ array [ $ j ] = $ tmp ; } } | Shuffles the array using a Seed . |
26,660 | public function setUserData ( User $ user ) { $ userVarArray = get_object_vars ( $ user ) ; foreach ( $ userVarArray as $ key => $ value ) { if ( $ value !== null ) { $ this -> { $ key } = $ value ; } } } | Dynamicly set user properties to its value . |
26,661 | public function findAllUsers ( ) { $ this -> checkDb ( ) ; return $ this -> db -> connect ( ) -> select ( ) -> from ( $ this -> tableName ) -> where ( "deleted IS NULL" ) -> execute ( ) -> fetchAllClass ( get_class ( $ this ) ) ; } | Returns all users stored and that are not deleted . |
26,662 | public function removeDir ( $ path ) { if ( $ path == 'packages' or $ path == '/' ) { return false ; } $ files = array_diff ( scandir ( $ path ) , [ '.' , '..' ] ) ; foreach ( $ files as $ file ) { if ( is_dir ( "$path/$file" ) ) { $ this -> removeDir ( "$path/$file" ) ; } else { @ chmod ( "$path/$file" , 0777 ) ; @ unlink ( "$path/$file" ) ; } } return rmdir ( $ path ) ; } | Remove a directory if it exists . |
26,663 | public function delete ( $ id = null ) { if ( ! $ id ) { $ id = $ this -> data -> id ; } return $ this -> client -> delete ( '/{id}' , [ 'id' => $ id ] ) ; } | Delete a notification preference |
26,664 | public function setWebHook ( $ url ) { $ this -> data -> target = $ url ; $ this -> data -> media = self :: DEFAULT_MEDIA ; return $ this ; } | Set WebHook URL |
26,665 | public function setEventsList ( array $ events ) { $ this -> data -> events = array_merge ( $ this -> data -> events , $ events ) ; return $ this ; } | Set a list of events name |
26,666 | public function getEntityName ( ) { if ( null == $ this -> entityName ) { $ this -> setEntityName ( get_class ( $ this -> getEntity ( ) ) ) ; } return $ this -> entityName ; } | Gets the entity class name that triggers the event |
26,667 | protected function replace ( $ text , $ replacements ) { if ( is_array ( $ replacements ) ) { foreach ( $ replacements as $ var => $ replacement ) { $ regex = str_replace ( 'key' , preg_quote ( $ var , '/' ) , $ this -> translateReplaceRegex ) ; $ text = preg_replace ( $ regex , $ replacement , $ text ) ; } } return $ text ; } | Replace text variables . |
26,668 | public function _ ( $ text , $ replacements = null , $ locale = null ) { if ( ! $ locale ) { $ locale = $ this -> getLocale ( ) ; } if ( $ this -> translator !== null ) { $ text = $ this -> translator -> translate ( $ text , $ locale ) ; } return $ this -> replace ( $ text , $ replacements ) ; } | Translate a text . |
26,669 | public function _n ( $ textSingular , $ textPlural , $ number , $ replacements = null , $ locale = null ) { if ( ! $ locale ) { $ locale = $ this -> getLocale ( ) ; } if ( $ this -> translator !== null ) { $ text = $ this -> translator -> translatePlurals ( $ textSingular , $ textPlural , $ number , $ locale ) ; } else { $ text = $ number == 1 ? $ textSingular : $ textPlural ; } return $ this -> replace ( $ text , $ replacements ) ; } | Translate the given text based on the given number . |
26,670 | public function formatDateTime ( \ DateTime $ datetime , $ format , $ calendar = \ IntlDateFormatter :: GREGORIAN ) { $ types = array ( \ IntlDateFormatter :: NONE , \ IntlDateFormatter :: NONE , ) ; if ( is_array ( $ format ) ) { if ( isset ( $ format [ 0 ] ) ) { $ types [ 0 ] = $ format [ 0 ] ; } if ( isset ( $ format [ 1 ] ) ) { $ types [ 1 ] = $ format [ 1 ] ; } $ pattern = null ; } else { $ pattern = $ format ; } $ formatter = new \ IntlDateFormatter ( $ this -> currentLocale , $ types [ 0 ] , $ types [ 1 ] , $ datetime -> getTimezone ( ) -> getName ( ) , $ calendar , $ pattern ) ; return $ formatter -> format ( $ datetime ) ; } | Format DateTime to current locale format . |
26,671 | public function getSender ( ) { $ sender = $ this -> createSender ( ) ; $ sender -> setFrom ( $ this -> fromEmail , $ this -> fromName ) ; if ( $ this -> replyToEmail ) { $ sender -> setReplyTo ( $ this -> replyToEmail ) ; } return $ sender ; } | Creates a sender instance and sets the from email & name and reply to address . |
26,672 | public function loadFaqs ( ) : array { return $ this -> repository -> matching ( $ this -> repository -> criteria ( ) -> orderByAsc ( Faq :: ORDER_TO_DISPLAY ) ) ; } | Loads the FAQ s |
26,673 | public static function D2tf ( $ ndp , $ days , & $ sign , array & $ ihmsf ) { $ nrs ; $ n ; $ rs ; $ rm ; $ rh ; $ a ; $ w ; $ ah ; $ am ; $ as ; $ af ; $ sign = $ days >= 0.0 ? '+' : '-' ; $ a = DAYSEC * abs ( $ days ) ; if ( $ ndp < 0 ) { $ nrs = 1 ; for ( $ n = 1 ; $ n <= - $ ndp ; $ n ++ ) { $ nrs *= ( $ n == 2 || $ n == 4 ) ? 6 : 10 ; } $ rs = ( double ) $ nrs ; $ w = $ a / $ rs ; $ a = $ rs * intval ( $ w ) ; } $ nrs = 1 ; for ( $ n = 1 ; $ n <= $ ndp ; $ n ++ ) { $ nrs *= 10 ; } $ rs = ( double ) $ nrs ; $ rm = $ rs * 60.0 ; $ rh = $ rm * 60.0 ; $ a = round ( $ rs * $ a ) ; $ ah = $ a / $ rh ; $ ah = intval ( $ ah ) ; $ a -= $ ah * $ rh ; $ am = $ a / $ rm ; $ am = intval ( $ am ) ; $ a -= $ am * $ rm ; $ as = $ a / $ rs ; $ as = intval ( $ as ) ; $ af = $ a - $ as * $ rs ; $ ihmsf [ 0 ] = ( int ) $ ah ; $ ihmsf [ 1 ] = ( int ) $ am ; $ ihmsf [ 2 ] = ( int ) $ as ; $ ihmsf [ 3 ] = ( int ) $ af ; return ; } | - - - - - - - - i a u D 2 t f - - - - - - - - |
26,674 | protected function replaceExtension ( $ filename , $ ext ) { $ ext = str_replace ( '.' , '' , $ ext ) ; $ filename = $ this -> removeExtension ( $ filename ) ; return $ filename . '.' . $ ext ; } | Remove a filename extension . |
26,675 | public function guessConvert ( $ value , $ destinationUnit , $ locale = null ) { $ result = array ( ) ; if ( preg_match ( '#([\d,\.\s]+)\s*([^\s]+)#' , $ value , $ result ) > 0 ) { return $ this -> convert ( \ floatval ( \ str_replace ( array ( ',' , ' ' ) , array ( '.' , '' ) , $ result [ 1 ] ) ) , $ result [ 2 ] , $ destinationUnit , $ locale ) ; } return null ; } | Tries to guess the source unit by parsing the string and then apply a convertion . Returns null if fails or not supported . |
26,676 | public function onKernelResponse ( FilterResponseEvent $ event ) { $ response = $ event -> getResponse ( ) ; if ( $ response instanceof SerializedResponse ) { $ acceptableContentTypes = $ event -> getRequest ( ) -> getAcceptableContentTypes ( ) ; $ format = 'json' ; foreach ( $ acceptableContentTypes as $ item ) { if ( strpos ( $ item , 'xml' ) !== false ) { $ format = 'xml' ; break ; } } $ serializedData = $ this -> serializer -> serialize ( $ response -> getData ( ) , $ format , null ) ; $ response -> setContent ( $ serializedData ) ; } } | Modify the Response given the Request if the Response is a instance of SerializedResponse . |
26,677 | protected function buildLists ( ) { $ lists = array ( ) ; $ langList = array ( ) ; $ path = $ this -> config [ 'lang.path' ] ; $ objects = new RII ( new RDI ( $ path ) , RII :: SELF_FIRST ) ; foreach ( $ objects as $ object ) { if ( $ object -> getExtension ( ) === 'php' ) { $ pathName = $ object -> getPathName ( ) ; $ explodedPathName = explode ( '/' , dirname ( $ pathName ) ) ; $ fileName = end ( $ explodedPathName ) ; $ langList [ $ fileName ] = true ; $ lists [ $ fileName ] = require_once $ pathName ; } } $ this -> langList = $ langList ; $ this -> list = $ this -> arrayDot ( $ lists ) ; } | Build list of translation and available language in specific folder |
26,678 | protected function getAppBasePath ( ) { $ path = dirname ( $ _SERVER [ 'SCRIPT_FILENAME' ] ) ; return ( is_link ( $ path ) ) ? dirname ( readlink ( $ path ) ) : dirname ( $ path ) ; } | Get absolute path of working application |
26,679 | public function event ( Closure $ event ) { if ( null !== $ response = $ event ( ) ) { $ this -> resolveEventResponse ( $ response ) ; } return $ this ; } | add a event |
26,680 | private function resolveEventResponse ( $ response ) { if ( is_string ( $ response ) ) { $ response = new ExecTask ( $ response ) ; } if ( $ response instanceof TaskReposity && ! $ response instanceof ClosureTask ) { EventReposity :: addBasic ( $ response ) ; } else { throw new CronInstanceException ( sprintf ( 'Event Response must be an instance of %s and cant be an instance of %s' , TaskReposity :: class , ClosureTask :: class ) ) ; } } | resolve the response from add event method |
26,681 | public function removeJob ( $ job = '' ) { if ( $ job instanceof TaskReposity ) { $ job = $ job -> buildCommandWithExpression ( ) ; } $ refrector = new CronEntry ( ) ; $ job = $ refrector -> parse ( $ job ) ; $ this -> getManager ( ) -> removeJob ( $ job ) ; return $ this ; } | remove a job |
26,682 | public function inputText ( $ text , $ defaultValue = '' ) { $ defaultValueStr = '' ; if ( $ defaultValue != '' ) { $ defaultValueStr = '[' . $ defaultValue . '] ' ; } echo $ text . ' ' . $ defaultValueStr ; $ handle = fopen ( 'php://stdin' , 'r' ) ; $ line = fgets ( $ handle ) ; $ preparedLine = strtolower ( trim ( $ line ) ) ; if ( $ preparedLine === '' ) { $ preparedLine = $ defaultValue ; } return $ preparedLine ; } | Asks the cli user for input text . |
26,683 | public function inject ( Response & $ response ) { $ renderer = $ this -> debugBar -> getJavascriptRenderer ( '/__debug__/' ) ; if ( stripos ( $ response -> headers -> get ( 'Content-Type' ) , 'text/html' ) === 0 ) { $ content = $ response -> getContent ( ) ; $ content = self :: injectHtml ( $ content , $ renderer -> renderHead ( ) , '</head>' ) ; $ content = self :: injectHtml ( $ content , $ renderer -> render ( ) , '</body>' ) ; $ response -> setContent ( $ content ) ; } } | Inject the debug bar . |
26,684 | private static function injectHtml ( $ html , $ code , $ before ) { $ pos = strripos ( $ html , $ before ) ; if ( $ pos === false ) { return $ html . $ code ; } return substr ( $ html , 0 , $ pos ) . $ code . substr ( $ html , $ pos ) ; } | Inject html code before a tag . |
26,685 | public function serve ( ResponseInterface $ response , $ cookies = [ ] ) { if ( headers_sent ( $ file , $ line ) ) { throw new HeadersSentException ( 'Headers already sent in ' . $ file . ' on line ' . $ line ) ; } $ this -> triggerEvent ( 'serve' , new \ Jivoo \ Event ( $ this , [ 'response' => $ response , 'cookies' => $ cookies ] ) ) ; $ this -> serveStatus ( $ response ) ; $ this -> serveCookies ( $ cookies ) ; $ this -> serveHeaders ( $ response ) ; $ this -> serveBody ( $ response , $ this -> compression ) ; $ this -> triggerEvent ( 'served' , new \ Jivoo \ Event ( $ this , [ 'response' => $ response , 'cookies' => $ cookies ] ) ) ; } | Serve a response . |
26,686 | protected function serveStatus ( ResponseInterface $ response ) { $ protocol = $ response -> getProtocolVersion ( ) ; $ status = $ response -> getStatusCode ( ) ; $ reason = $ response -> getReasonPhrase ( ) ; if ( $ reason != '' ) { $ reason = ' ' . $ reason ; } header ( 'HTTP/' . $ protocol . ' ' . $ status . $ reason ) ; } | Set the status line . |
26,687 | protected function serveCookies ( $ cookies ) { foreach ( $ cookies as $ cookie ) { if ( $ cookie -> hasChanged ( ) ) { $ expiration = $ cookie -> getExpiration ( ) ; if ( isset ( $ expiration ) ) { $ expiration = $ expiration -> getTimestamp ( ) ; } else { $ expiration = 0 ; } setcookie ( $ cookie -> getName ( ) , $ cookie -> get ( ) , $ expiration , $ cookie -> getPath ( ) , $ cookie -> getDomain ( ) , $ cookie -> isSecure ( ) , $ cookie -> isHttpOnly ( ) ) ; } } } | Set the cookies . |
26,688 | protected function serveHeaders ( ResponseInterface $ response ) { header_remove ( 'X-Powered-By' ) ; foreach ( $ response -> getHeaders ( ) as $ header => $ values ) { header ( $ header . ': ' . array_shift ( $ values ) , true ) ; foreach ( $ values as $ value ) { header ( $ header . ': ' . $ value , false ) ; } } } | Set the headers . |
26,689 | protected function serveBody ( ResponseInterface $ response , $ compression = null ) { $ body = $ response -> getBody ( ) ; $ body -> rewind ( ) ; $ out = fopen ( 'php://output' , 'wb' ) ; if ( $ compression == 'bzip2' ) { fwrite ( $ out , bzcompress ( $ body -> getContents ( ) ) ) ; } elseif ( $ compression == 'gzip' ) { fwrite ( $ out , gzencode ( $ body -> getContents ( ) ) ) ; } else { while ( ! $ body -> eof ( ) ) { fwrite ( $ out , $ body -> read ( 8192 ) ) ; } } fclose ( $ out ) ; $ body -> close ( ) ; } | Output the response body . |
26,690 | public function listen ( ) { $ request = $ this -> request ; $ response = new Response ( Status :: OK ) ; $ first = $ this -> getNext ( $ this -> middleware ) ; $ response = $ first ( $ request , $ response ) ; $ this -> serve ( $ response , $ this -> getCookies ( ) ) ; } | Start server i . e . create a response for the current request using the available middleware and request handler . |
26,691 | public function handleRefreshToken ( AccessToken $ previousToken , int $ tries ) : AccessToken { return $ this -> client -> getConfiguration ( ) -> refreshToken ( $ previousToken -> getRefreshToken ( ) ) ; } | Take care of refreshing the token |
26,692 | public static function populateValidator ( Validator $ validator ) { if ( static :: $ provider === null ) { static :: setProvider ( new FromArray ( true , 'validation' ) ) ; } return static :: $ provider -> populateValidator ( $ validator ) ; } | Populates the given validator with the needed rules |
26,693 | public function first ( array $ parameter = [ ] ) { $ parameter = array_merge ( $ this -> parameter , $ parameter ) ; $ query = $ this -> model ; if ( array_key_exists ( self :: FILTER_KEY , $ parameter ) ) { foreach ( $ parameter [ self :: FILTER_KEY ] as $ field => $ filter ) { if ( ! is_array ( $ filter ) ) { $ query = $ query -> where ( $ field , '=' , $ filter ) ; } else { if ( array_key_exists ( 'or' , $ filter ) ) { if ( $ filter [ 'or' ] ) { $ query = $ query -> orWhere ( $ filter [ 'field' ] , $ filter [ 'operator' ] , $ filter [ 'value' ] ) ; } } else { $ query = $ query -> where ( $ filter [ 'field' ] , $ filter [ 'operator' ] , $ filter [ 'value' ] ) ; } } } } if ( array_key_exists ( self :: ORDER_KEY , $ parameter ) ) { foreach ( $ parameter [ self :: ORDER_KEY ] as $ field => $ direction ) { $ query = $ query -> orderBy ( $ field , $ direction ) ; } } if ( array_key_exists ( self :: EMBED_KEY , $ parameter ) ) { foreach ( $ parameter [ self :: EMBED_KEY ] as $ relationship ) { $ this -> eagerLoad ( $ relationship ) ; } } $ result = $ this -> retrieve ( $ query ) ; switch ( $ result -> count ( ) ) { case 0 : return new Payload ( $ result , 'not_found' ) ; break ; default : return new Payload ( $ result -> first ( ) , 'found' ) ; break ; } } | Get a single object based on given parameters . |
26,694 | public function retrieve ( $ selectQuery ) { $ selectQuery = $ this -> setEagerLoaded ( $ selectQuery ) ; $ retrieved = $ selectQuery -> get ( ) ; return $ this -> setLazyLoaded ( $ retrieved ) ; } | Retrieve the data . |
26,695 | public function dispatch ( $ data ) { $ event = new \ Moxy \ Event ( $ this -> _name , $ data ) ; foreach ( $ this -> _listeners as $ listener ) { $ listener -> call ( $ event ) ; } } | Dispatch an Event |
26,696 | public function createAction ( Request $ request ) { $ entity = new Feature ( ) ; $ form = $ this -> createForm ( new FeatureType ( ) , $ entity ) ; $ form -> bind ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ entity ) ; $ em -> flush ( ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'feature.created' ) ; return $ this -> redirect ( $ this -> generateUrl ( 'ecommerce_feature_show' , array ( 'id' => $ entity -> getId ( ) ) ) ) ; } return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , ) ; } | Creates a new Feature entity . |
26,697 | public function newAction ( ) { $ entity = new Feature ( ) ; if ( $ this -> getRequest ( ) -> query -> has ( 'category' ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ category = $ em -> getRepository ( 'EcommerceBundle:Category' ) -> find ( $ this -> getRequest ( ) -> query -> get ( 'category' ) ) ; $ entity -> setCategory ( $ category ) ; } $ form = $ this -> createForm ( new FeatureType ( ) , $ entity ) ; return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , ) ; } | Displays a form to create a new Feature entity . |
26,698 | public function sortAction ( Request $ request , $ categoryId ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ category = $ em -> getRepository ( 'EcommerceBundle:Category' ) -> find ( $ categoryId ) ; if ( ! $ category ) { throw $ this -> createNotFoundException ( 'Unable to find Category entity.' ) ; } if ( $ request -> isXmlHttpRequest ( ) ) { $ this -> get ( 'admin_manager' ) -> sort ( 'EcommerceBundle:Feature' , $ request -> get ( 'values' ) ) ; return new Response ( 0 , 200 ) ; } $ features = $ em -> getRepository ( 'EcommerceBundle:Feature' ) -> findBy ( array ( 'category' => $ category ) , array ( 'order' => 'asc' ) ) ; return array ( 'features' => $ features , 'category' => $ category ) ; } | Sorts a list of features . |
26,699 | public function toggleFiltrableAction ( Request $ request , $ id ) { if ( false === $ request -> isXmlHttpRequest ( ) ) { throw $ this -> createNotFoundException ( ) ; } $ isFiltrable = $ this -> get ( 'admin_manager' ) -> toggleFiltrable ( 'EcommerceBundle:Feature' , $ id ) ; return new Response ( intval ( $ isFiltrable ) , 200 ) ; } | Set a list of features as filtrable . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.