idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
30,400 | public static function getParentForm ( BlockInterface $ block ) { $ form = $ block -> getForm ( ) ; if ( null !== $ form ) { return $ form ; } return null !== $ block -> getParent ( ) ? static :: getParentForm ( $ block -> getParent ( ) ) : null ; } | Get the parent form . |
30,401 | public static function createFormView ( BlockView $ view , BlockInterface $ block ) { $ parentForm = static :: getParentFormView ( $ view ) ; if ( null !== $ parentForm ) { $ formPath = $ block -> hasOption ( 'form_path' ) && null !== $ block -> getOption ( 'form_path' ) ? $ block -> getOption ( 'form_path' ) : $ block -> getName ( ) ; $ formNames = explode ( '.' , $ formPath ) ; $ form = $ parentForm -> vars [ 'form' ] ; foreach ( $ formNames as $ formName ) { if ( isset ( $ form -> children [ $ formName ] ) ) { $ form = $ form -> children [ $ formName ] ; } } if ( $ form !== $ parentForm -> vars [ 'form' ] ) { return $ form ; } } return $ block -> getForm ( ) -> createView ( $ parentForm ) ; } | Create form view . |
30,402 | public static function getParentFormView ( BlockView $ view ) { if ( isset ( $ view -> vars [ 'block_form' ] ) && null !== $ view -> vars [ 'block_form' ] ) { return $ view -> vars [ 'block_form' ] ; } return null !== $ view -> parent ? static :: getParentFormView ( $ view -> parent ) : null ; } | Get the parent form view . |
30,403 | public function Check ( $ value ) { if ( ! \ in_array ( $ value , $ this -> values ) ) $ this -> error = self :: NotInArray ; return $ this -> error == '' ; } | Checks if the value is in the array of allowed values |
30,404 | public function init ( ) { $ kubernetesClient = $ this -> controller -> getKubernetesClient ( ) ; $ storeNamespace = $ this -> namespace ; $ storeName = $ this -> name ; $ response = $ kubernetesClient -> request ( "/api/v1/namespaces/${storeNamespace}/configmaps/${storeName}" ) ; if ( $ response [ 'status' ] == 'Failure' ) { $ data = [ 'kind' => 'ConfigMap' , 'metadata' => [ 'name' => $ storeName , ] , 'data' => null , ] ; $ response = $ kubernetesClient -> request ( "/api/v1/namespaces/${storeNamespace}/configmaps" , 'POST' , [ ] , $ data ) ; if ( $ response [ 'status' ] == 'Failure' ) { $ this -> log ( $ response [ 'message' ] ) ; return ; } } if ( ! empty ( $ response [ 'data' ] ) ) { array_walk ( $ response [ 'data' ] , function ( & $ item , $ key ) { $ item = json_decode ( $ item , true ) ; } ) ; } $ this -> data = $ response [ 'data' ] ; $ params = [ 'resourceVersion' => $ response [ 'metadata' ] [ 'resourceVersion' ] , ] ; $ watch = $ kubernetesClient -> createWatch ( "/api/v1/watch/namespaces/${storeNamespace}/configmaps/${storeName}" , $ params , $ this -> getConfigMapWatchCallback ( ) ) ; $ this -> addWatch ( $ watch ) ; $ this -> initialized = true ; $ this -> controller -> log ( 'store successfully initialized' ) ; } | Initialize the store |
30,405 | private function getConfigMapWatchCallback ( ) { return function ( $ event , $ watch ) { switch ( $ event [ 'type' ] ) { case 'ADDED' : case 'MODIFIED' : if ( ! empty ( $ event [ 'object' ] [ 'data' ] ) ) { array_walk ( $ event [ 'object' ] [ 'data' ] , function ( & $ item , $ key ) { $ item = json_decode ( $ item , true ) ; } ) ; } $ this -> data = $ event [ 'object' ] [ 'data' ] ; break ; case 'DELETED' : $ this -> data = null ; break ; } } ; } | Callback used by the ConfimMap watch |
30,406 | public function set ( $ key , $ value ) { $ kubernetesClient = $ this -> controller -> getKubernetesClient ( ) ; $ storeNamespace = $ this -> namespace ; $ storeName = $ this -> name ; $ data = [ 'kind' => 'ConfigMap' , 'metadata' => [ 'name' => $ storeName ] , 'data' => [ $ key => json_encode ( $ value ) , ] , ] ; $ response = $ kubernetesClient -> request ( "/api/v1/namespaces/${storeNamespace}/configmaps/${storeName}" , 'PATCH' , [ ] , $ data ) ; if ( $ response [ 'status' ] == 'Failure' ) { $ this -> controller -> log ( $ response [ 'message' ] ) ; return false ; } return true ; } | Set store value |
30,407 | public function isImage ( ) { $ mime = $ this -> getMimeType ( ) ; foreach ( $ this -> imageMimes as $ imageMime ) { if ( in_array ( $ mime , ( array ) $ imageMime ) ) { return true ; } } return false ; } | Method for determining whether the uploaded file is an image type . |
30,408 | public function getItemId ( Item $ item ) { foreach ( $ item -> getSources ( ) as $ source ) { if ( strpos ( $ source -> getUrl ( ) , $ this -> browser -> getHost ( ) ) === 0 && preg_match ( self :: REG_ITEM_ID , $ source -> getUrl ( ) , $ match ) ) { return ( int ) $ match [ 'id' ] ; } } return 0 ; } | Get Shikimori item id from sources |
30,409 | public function hash ( array $ list ) { $ ids = '' ; foreach ( $ list as $ item ) { $ ids .= ':' . $ item [ 'id' ] ; } return md5 ( $ ids ) ; } | Get hash from list items |
30,410 | public function getWidgetItem ( array $ item ) { $ entity = new ItemWidget ( ) ; $ entity -> setName ( $ this -> getItemName ( $ item ) ) ; $ entity -> setLink ( $ this -> browser -> getHost ( ) . $ item [ 'url' ] ) ; $ entity -> setCover ( $ this -> browser -> getHost ( ) . $ item [ 'image' ] [ 'original' ] ) ; $ catalog_item = $ this -> getCatalogItem ( $ item ) ; if ( $ catalog_item instanceof Item ) { $ entity -> setItem ( $ catalog_item ) ; } elseif ( $ this -> filler instanceof Filler ) { $ entity -> setLinkForFill ( $ this -> filler -> getLinkForFill ( $ entity -> getLink ( ) ) ) ; } return $ entity ; } | Get widget item |
30,411 | public function getItemName ( array $ item ) { if ( $ this -> locale == 'ru' && $ item [ 'russian' ] ) { return $ item [ 'russian' ] ; } if ( $ this -> locale == 'ja' && $ item [ 'japanese' ] ) { return $ item [ 'japanese' ] [ 0 ] ; } if ( $ this -> locale == 'en' && $ item [ 'english' ] ) { return $ item [ 'english' ] [ 0 ] ; } return $ item [ 'name' ] ; } | Get item name |
30,412 | public function getCatalogItem ( array $ item ) { $ sources = [ $ this -> browser -> getHost ( ) . $ item [ 'url' ] ] ; if ( ! empty ( $ item [ 'world_art_id' ] ) ) { $ sources [ ] = str_replace ( '#ID#' , $ item [ 'world_art_id' ] , self :: WORLD_ART_URL ) ; } if ( ! empty ( $ item [ 'myanimelist_id' ] ) ) { $ sources [ ] = str_replace ( '#ID#' , $ item [ 'myanimelist_id' ] , self :: MY_ANIME_LIST_URL ) ; } if ( ! empty ( $ item [ 'ani_db_id' ] ) ) { $ sources [ ] = str_replace ( '#ID#' , $ item [ 'ani_db_id' ] , self :: ANI_DB_URL ) ; } $ source = $ this -> repository -> findOneBy ( [ 'url' => $ sources ] ) ; if ( $ source instanceof Source ) { return $ source -> getItem ( ) ; } return null ; } | Get catalog item |
30,413 | public static function factory ( $ type = '' , $ message = '' , $ code = 0 , Exception $ previous = null ) { if ( file_exists ( __DIR__ . ucfirst ( $ type ) . 'Exception.php' ) ) { include_once __DIR__ . ucfirst ( $ type ) . 'Exception.php' ; $ classname = 'Whoisdoma\DomainParser\Exception\\' . ucfirst ( $ type ) . 'Exception' ; return new $ classname ( $ message , $ code , $ previous ) ; } else { include_once __DIR__ . '/Exception.php' ; $ classname = 'Whoisdoma\DomainParser\Exception\Exception' ; return new $ classname ( $ message , $ code , $ previous ) ; } } | Creates an exception object |
30,414 | public function cookiejar ( $ cookiefile ) { $ this -> userOpt [ CURLOPT_COOKIEFILE ] = $ cookiefile ; $ this -> userOpt [ CURLOPT_COOKIEJAR ] = $ cookiefile ; } | Register cookie jar . |
30,415 | public function setOpt ( $ opt ) { if ( $ this -> currentStep > 0 ) { throw new \ Exception ( "setOpt method must be called before exec method." , 1 ) ; } foreach ( $ opt as $ key => $ value ) { $ this -> userOpt [ $ key ] = $ value ; } } | Define user opt . |
30,416 | private function buildHeaderResponse ( ) { foreach ( explode ( "\n" , substr ( $ this -> output , 0 , $ this -> info [ 'header_size' ] ) ) as $ val ) { $ val = trim ( $ val ) ; if ( ! empty ( $ val ) ) { $ this -> headerResponse [ ] = $ val ; } } $ this -> output = substr ( $ this -> output , $ this -> info [ 'header_size' ] ) ; } | Build header response context . |
30,417 | private function buildOpt ( ) { foreach ( $ this -> defaultOpt as $ key => $ val ) { $ this -> opt [ $ key ] = $ val ; } foreach ( $ this -> userOpt as $ key => $ val ) { $ this -> opt [ $ key ] = $ val ; } } | Build opt context . |
30,418 | private function urlGen ( $ url ) { if ( empty ( $ url ) && empty ( $ this -> url ) ) { throw new \ Exception ( "URL not set!" , 1 ) ; } return empty ( $ url ) ? $ this -> url : $ url ; } | Private url check . |
30,419 | private function ensureParentAndKey ( $ parent , $ key ) { if ( ! $ this -> parent ) { $ this -> parent = $ parent ; } if ( ! $ this -> key ) { $ this -> key = $ key ; } if ( $ this -> parent != $ parent ) { throw new \ Exception ( 'Internal Error. Relation retrieved from two different Objects.' ) ; } if ( $ this -> key != $ key ) { throw new \ Exception ( 'Internal Error. Relation retrieved from two different keys.' ) ; } } | Makes sure that this relation has the right parent and key . |
30,420 | public function add ( $ objects ) { if ( ! is_array ( $ objects ) ) { $ objects = [ $ objects ] ; } $ operation = new AVRelationOperation ( $ objects , null ) ; $ this -> targetClassName = $ operation -> _getTargetClass ( ) ; $ this -> parent -> _performOperation ( $ this -> key , $ operation ) ; } | Adds a AVObject or an array of AVObjects to the relation . |
30,421 | public function getQuery ( ) { $ query = new AVQuery ( $ this -> targetClassName ) ; $ query -> relatedTo ( 'object' , $ this -> parent -> _toPointer ( ) ) ; $ query -> relatedTo ( 'key' , $ this -> key ) ; return $ query ; } | Gets a query that can be used to query the objects in this relation . |
30,422 | private function processResponse ( ResponseInterface $ response ) { if ( $ response -> getStatusCode ( ) != 200 ) { throw new YouHostingException ( "The API returned with a non-successful error code: " . $ response -> getStatusCode ( ) ) ; } $ json = $ response -> json ( ) ; if ( ! empty ( $ json [ 'error' ] ) ) { throw new YouHostingException ( $ json [ 'error' ] [ 'message' ] , $ json [ 'error' ] [ 'code' ] ) ; } return $ json [ 'result' ] ; } | Preprocess the result to check whether the request was successful |
30,423 | protected function mergeEvents ( $ events ) { $ result = array ( ) ; foreach ( $ events as $ event ) { if ( $ event -> getInline ( ) ) { $ code = $ event -> getCode ( ) . PHP_EOL ; } else { $ code = $ this -> buildHandlerFunctionCall ( $ event ) . PHP_EOL ; } if ( ! isset ( $ result [ $ event -> getName ( ) ] ) ) { $ result [ $ event -> getName ( ) ] = '' ; } $ result [ $ event -> getName ( ) ] .= $ code ; } return $ result ; } | Merges the handling codes of events with the same name . |
30,424 | protected function _getLimit ( $ key = null , $ default = null ) { $ result = ( int ) $ default ; if ( empty ( $ key ) ) { return $ result ; } $ data = $ this -> getConfig ( 'LdapSync.Limits.' . $ key ) ; if ( ( $ data === null ) || ! is_int ( $ data ) ) { return $ result ; } $ data = ( int ) $ data ; if ( $ data < 0 ) { return $ result ; } return $ data ; } | Return value of limit by configuration key . |
30,425 | public function getFlagTreeSubordinateEnable ( ) { $ flagTreeEnable = ( bool ) $ this -> getConfig ( 'LdapSync.TreeSubordinate.Enable' ) ; if ( ! $ flagTreeEnable ) { return false ; } $ ldapFieldsInfo = $ this -> getLdapFieldsInfo ( ) ; if ( ! isset ( $ ldapFieldsInfo [ CAKE_LDAP_LDAP_ATTRIBUTE_MANAGER ] ) ) { return false ; } return true ; } | Return state of flag enabling subordinate tree |
30,426 | public function getFlagTreeSubordinateDraggable ( ) { $ flagTreeDraggable = ( bool ) $ this -> getConfig ( 'LdapSync.TreeSubordinate.Draggable' ) ; if ( ! $ flagTreeDraggable ) { return false ; } if ( ! $ this -> getFlagTreeSubordinateEnable ( ) ) { return false ; } return true ; } | Return state of flag enabling changing position of employee in subordinate tree |
30,427 | public function getLocalFieldsInfo ( ) { $ language = ( string ) Configure :: read ( 'Config.language' ) ; $ cachePath = 'local_fields_info_' . $ language ; $ cached = Cache :: read ( $ cachePath , CAKE_LDAP_CACHE_KEY_CONFIG ) ; if ( $ cached !== false ) { return $ cached ; } $ localFieldsConfig = [ 'id' => [ 'label' => null , 'altLabel' => null , 'priority' => 0 , 'rules' => [ 'naturalNumber' => [ 'rule' => [ 'naturalNumber' ] , 'message' => 'Incorrect primary key' , 'allowEmpty' => false , 'required' => true , 'last' => true , 'on' => 'update' ] , ] , 'default' => null ] , 'department_id' => [ 'label' => null , 'altLabel' => null , 'priority' => 0 , 'rules' => [ 'naturalNumber' => [ 'rule' => [ 'naturalNumber' ] , 'message' => 'Incorrect foreign key' , 'allowEmpty' => true , 'required' => true , 'last' => true , ] , ] , 'default' => null ] , 'manager_id' => [ 'label' => null , 'altLabel' => null , 'priority' => 0 , 'rules' => [ 'naturalNumber' => [ 'rule' => [ 'naturalNumber' ] , 'message' => 'Incorrect foreign key' , 'allowEmpty' => true , 'required' => false , 'last' => true , ] , ] , 'default' => null ] , 'block' => [ 'label' => __d ( 'cake_ldap_field_name' , 'Block' ) , 'altLabel' => __d ( 'cake_ldap_field_name' , 'Block' ) , 'priority' => 100 , 'rules' => [ 'boolean' => [ 'rule' => [ 'boolean' ] , 'message' => 'Incorrect state of blocking' , 'allowEmpty' => true , 'required' => false , 'last' => false , ] , ] , 'default' => false ] , ] ; $ localFieldsList = [ 'id' , ] ; $ ldapFieldsList = $ this -> _getListBindFields ( ) ; $ ldapFieldsConfig = $ this -> getLdapFieldsInfo ( ) ; foreach ( $ ldapFieldsList as $ ldapFieldName => $ localFieldName ) { if ( isset ( $ ldapFieldsConfig [ $ ldapFieldName ] ) && ! empty ( $ localFieldName ) ) { $ localFieldsList [ ] = $ localFieldName ; } } if ( ! $ this -> getFlagDeleteEmployees ( ) ) { $ localFieldsList [ ] = 'block' ; } $ result = array_intersect_key ( $ localFieldsConfig , array_flip ( $ localFieldsList ) ) ; Cache :: write ( $ cachePath , $ result , CAKE_LDAP_CACHE_KEY_CONFIG ) ; return $ result ; } | Return informations about local fields of table employees |
30,428 | public function getLdapFieldsInfo ( ) { $ language = ( string ) Configure :: read ( 'Config.language' ) ; $ cachePath = 'ldap_fields_info_' . $ language ; $ cached = Cache :: read ( $ cachePath , CAKE_LDAP_CACHE_KEY_CONFIG ) ; if ( $ cached !== false ) { return $ cached ; } $ result = [ ] ; $ data = ( array ) $ this -> getConfig ( 'LdapSync.LdapFields' ) ; if ( empty ( $ data ) ) { return $ result ; } $ modelEmployeeLdap = ClassRegistry :: init ( 'CakeLdap.EmployeeLdap' ) ; $ schema = $ modelEmployeeLdap -> schema ( ) ; if ( empty ( $ schema ) ) { $ schema = [ ] ; } $ requiredFields = $ modelEmployeeLdap -> getRequiredFields ( ) ; $ data += array_flip ( $ requiredFields ) ; $ result = array_intersect_key ( $ data , $ schema ) ; Cache :: write ( $ cachePath , $ result , CAKE_LDAP_CACHE_KEY_CONFIG ) ; return $ result ; } | Returns information about the local fields of table employees based on the LdapFields configuration from the plugin configuration file |
30,429 | public function getListFieldsDb ( ) { $ result = [ ] ; $ fieldsInfo = $ this -> getLocalFieldsInfo ( ) ; $ fieldsInfo += $ this -> getLdapFieldsInfo ( ) ; if ( empty ( $ fieldsInfo ) ) { return $ result ; } $ excludeFields = $ this -> _getListBindFields ( ) ; $ fields = array_keys ( $ fieldsInfo ) ; $ result = array_values ( array_diff ( $ fields , array_keys ( $ excludeFields ) ) ) ; return $ result ; } | Returns list of local fields of table employees |
30,430 | public function getId ( ) { return $ this -> getCachedProperty ( 'id' , function ( ) { return $ this -> getExtensions ( ) -> parseElement ( $ this , $ this -> query ( 'atom:id' , Node :: SINGLE | Node :: REQUIRED ) ) ; } ) ; } | Return permanent universally unique identifier for an entry or feed . |
30,431 | protected static function addTranslation ( $ file , $ string ) { static :: $ loaded [ $ file ] = array_merge ( static :: $ loaded [ $ file ] , [ $ string => '' ] ) ; static :: saveTranslationFile ( $ file , static :: $ loaded [ $ file ] ) ; return $ string ; } | Add missing string to an existing locale |
30,432 | protected static function TranslationArrayExport ( $ array ) { $ output = "[\n" ; foreach ( $ array as $ key => $ value ) { $ key = str_replace ( '\'' , '\\\'' , $ key ) ; $ value = str_replace ( '\'' , '\\\'' , $ value ) ; $ output .= "\t'{$key}' => '{$value}',\n" ; } return $ output . "];" ; } | Like var_export but pretty |
30,433 | public static function windowsFileTimeToUnix ( $ time ) { $ magicnum = '116444735995904000' ; $ time = bcsub ( $ time , $ magicnum ) ; $ time = bcdiv ( $ time , '10000000' , 0 ) ; return apply_filters ( 'AdApi/Format/WindowsTime' , $ time ) ; } | Format Windows File Time to unix timestamp . |
30,434 | public static function parseDisplayName ( $ string , $ data ) { $ response = array ( ) ; if ( isset ( $ data -> sn ) && ! empty ( $ data -> sn ) ) { $ response [ 'firstname' ] = trim ( str_replace ( $ data -> sn , "" , substr ( $ string , 0 , strpos ( $ string , " - " ) ) ) ) ; $ response [ 'lastname' ] = $ data -> sn ; } elseif ( isset ( $ data -> mail ) && strpos ( $ data -> mail , "." ) ) { $ response [ 'firstname' ] = trim ( substr ( $ data -> mail , 0 , strpos ( $ data -> mail , "." ) ) ) ; $ response [ 'lastname' ] = trim ( substr ( $ data -> mail , strpos ( $ data -> mail , "." ) + 1 , strpos ( $ data -> mail , "@" ) - strpos ( $ data -> mail , "." ) - 1 ) ) ; } else { $ tempData = array ( ) ; $ tempData = trim ( substr ( $ string , 0 , strpos ( $ string , " - " ) ) ) ; if ( ! empty ( $ tempData ) ) { $ tempData = explode ( " " , $ tempData ) ; if ( is_array ( $ tempData ) && count ( $ tempData ) ) { $ response [ 'lastname' ] = $ tempData [ 0 ] ; unset ( $ tempData [ 0 ] ) ; $ response [ 'firstname' ] = implode ( " " , $ tempData ) ; } } } $ response [ 'firstname' ] = ucfirst ( $ response [ 'firstname' ] ) ; $ response [ 'lastname' ] = ucfirst ( $ response [ 'lastname' ] ) ; return $ response ; } | Parse display name to extract user firstname & lastname |
30,435 | protected function processInput ( $ global ) { if ( is_array ( $ global ) ) { $ this -> input = $ global ; } else { $ this -> target = $ global ; $ this -> input = $ GLOBALS [ $ global ] ; } $ this -> arguments = $ this -> transformToObject ( $ this -> input ) ; } | transforms input to object |
30,436 | public function key ( ) { $ i = 0 ; foreach ( $ this -> arguments as $ key => $ value ) { if ( $ i == $ this -> iteratorPosition ) { return $ key ; } ++ $ i ; } } | Returns the current position of iterator |
30,437 | public function get ( $ arguments = null ) { if ( ! is_null ( $ arguments ) ) { if ( isset ( $ this -> arguments [ $ arguments ] ) ) { return $ this -> arguments [ $ arguments ] ; } } return null ; } | Returns the value for the requested arguments if it exists otherwise NULL . |
30,438 | protected function setProperty ( $ key , $ value ) { $ this -> input [ $ key ] = $ value ; $ this -> arguments = $ this -> transformToObject ( $ this -> input ) ; } | Sets a property in arguments . |
30,439 | public function indexAction ( ) { $ this -> isAllowed ( 'BUSINESS_VIEW_ROLE' ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entities = $ em -> getRepository ( 'CanalTPSamCoreBundle:Role' ) -> findByIsEditable ( true ) ; return $ this -> render ( 'CanalTPSamEcoreSecurityBundle:Role:index.html.twig' , array ( 'entities' => $ entities , ) ) ; } | Lists all Role entities . |
30,440 | public function createAction ( Request $ request ) { $ this -> isAllowed ( 'BUSINESS_MANAGE_ROLE' ) ; $ model = new RegistrationRole ( ) ; $ form = $ this -> createCreateForm ( $ model ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ selectedApps = array ( ) ; foreach ( $ model -> applications as $ selectedApp ) { $ selectedApps [ ] = $ selectedApp -> getId ( ) ; } foreach ( $ model -> rolesByApplication as $ app ) { if ( in_array ( $ app -> getId ( ) , $ selectedApps ) ) { $ permissions = null === $ app -> getRole ( ) ? array ( ) : $ app -> getRole ( ) -> getPermissions ( ) ; $ role = new Role ( ) ; $ role -> setName ( $ model -> role -> getName ( ) ) ; $ role -> setApplication ( $ app ) ; $ role -> setPermissions ( $ permissions ) ; $ em -> persist ( $ role ) ; } } $ em -> flush ( ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'role.flash.created' ) ; return $ this -> redirect ( $ this -> generateUrl ( 'sam_role' ) ) ; } return $ this -> render ( 'CanalTPSamEcoreSecurityBundle:Role:new.html.twig' , array ( 'entity' => $ model , 'form' => $ form -> createView ( ) , ) ) ; } | Creates a new Role entity . |
30,441 | public function editAction ( Role $ role = null ) { $ this -> isAllowed ( 'BUSINESS_MANAGE_ROLE' ) ; if ( ! $ role ) { throw $ this -> createNotFoundException ( 'Unable to find Role entity.' ) ; } $ editForm = $ this -> createEditForm ( $ role ) ; return $ this -> render ( 'CanalTPSamEcoreSecurityBundle:Role:edit.html.twig' , array ( 'entity' => $ role , 'edit_form' => $ editForm -> createView ( ) ) ) ; } | Displays a form to edit an existing Role entity . |
30,442 | private function createEditForm ( Role $ entity ) { $ form = $ this -> createForm ( 'sam_role' , $ entity , array ( 'action' => $ this -> generateUrl ( 'sam_role_update' , array ( 'id' => $ entity -> getId ( ) ) ) , 'method' => 'PUT' , ) ) ; return $ form ; } | Creates a form to edit a Role entity . |
30,443 | public function updateAction ( Request $ request , Role $ role ) { $ this -> isAllowed ( 'BUSINESS_MANAGE_ROLE' ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; if ( ! $ role ) { throw $ this -> createNotFoundException ( 'Unable to find Role entity.' ) ; } $ editForm = $ this -> createEditForm ( $ role ) ; $ editForm -> handleRequest ( $ request ) ; if ( $ editForm -> isValid ( ) ) { $ em -> flush ( ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'role.flash.updated' ) ; return $ this -> redirect ( $ this -> generateUrl ( 'sam_role' ) ) ; } return $ this -> render ( 'CanalTPSamEcoreSecurityBundle:Role:edit.html.twig' , array ( 'entity' => $ role , 'edit_form' => $ editForm -> createView ( ) ) ) ; } | Edits an existing Role entity . |
30,444 | function build ( iRouterStack $ router ) { foreach ( $ this -> routes as $ routeName => $ routeValuable ) { $ route = $ routeValuable ; if ( is_string ( $ routeName ) && is_array ( $ routeValuable ) ) { $ route = $ this -> _attainRouteFromArray ( $ routeName , $ routeValuable ) ; $ override = ( isset ( $ routeValuable [ 'override' ] ) ) ? $ routeValuable [ 'override' ] : true ; $ priority = ( isset ( $ routeValuable [ 'priority' ] ) ) ? $ routeValuable [ 'priority' ] : null ; } if ( ! $ route instanceof iRoute ) throw new \ InvalidArgumentException ( sprintf ( 'Invalid argument provided. ("%s")' , \ Poirot \ Std \ flatten ( $ routeValuable ) ) ) ; if ( isset ( $ override ) && isset ( $ priority ) ) $ router -> add ( $ route , $ override , $ priority ) ; else $ router -> add ( $ route ) ; } } | Build Router Stack |
30,445 | protected function buildGlobalCodeOfEvent ( AbstractEvent $ event ) { $ result = '' ; if ( ! $ event -> getInline ( ) ) { $ result .= $ this -> buildHandlerFunction ( $ event ) ; } return $ result ; } | Builds the global code of a concrete event . |
30,446 | protected function buildInlineCodeOfEvent ( AbstractEvent $ event ) { if ( $ event -> getInline ( ) ) { $ code = $ event -> getCode ( ) . PHP_EOL ; } else { $ code = $ this -> buildHandlerFunctionCall ( $ event ) ; } $ condition = $ this -> buildCondition ( $ event ) ; if ( empty ( $ condition ) ) { $ result = $ code ; } else { $ result = ' if (' . $ condition . ') {' . PHP_EOL . $ code . ' }' . PHP_EOL ; } return $ result ; } | Builds the inline code of a concrete event . |
30,447 | protected function buildHandlerFunction ( $ event ) { return 'Void ' . $ this -> getHandlerFunctionName ( $ event ) . '(CMlEvent Event) {' . PHP_EOL . $ event -> getCode ( ) . PHP_EOL . '}' . PHP_EOL ; } | Builds the handler function of the event . |
30,448 | public function destroy ( $ memberTagId , $ id ) { $ member = Member :: findOrFail ( $ id ) ; $ this -> authorize ( 'detachMemberTagMember' , $ member ) ; $ member -> member_tags ( ) -> detach ( $ memberTagId ) ; return fractal ( $ member -> id , new DeletedTransformer ( ) ) -> withResourceName ( 'deletedMember' ) -> respond ( ) ; } | Remove an Member from the MemberTag . |
30,449 | public function index ( $ memberTagId ) { $ memberTag = MemberTag :: findOrFail ( $ memberTagId ) ; $ this -> authorize ( 'index' , $ memberTag ) ; $ memberTag -> load ( 'members' ) ; return fractal ( $ memberTag -> members , new MemberTransformer ( ) ) -> withResourceName ( 'memberTagMember' ) -> respond ( ) ; } | Produce a list of Members related to a selected MemberTag |
30,450 | public function store ( Request $ request ) { $ member = Member :: findOrFail ( $ request -> memberId ) ; $ this -> authorize ( 'attachMemberTagMember' , $ member ) ; $ request -> validate ( [ "memberId" => "exists:" . config ( 'combine-core.tablePrefix' , 'combine' ) . "_members,id" , "memberTagId" => "exists:" . config ( 'combine-core.tablePrefix' , 'combine' ) . "_member_tags,id" , ] ) ; $ member -> member_tags ( ) -> attach ( $ request -> memberTagId ) ; return fractal ( $ member , new MemberTransformer ( ) ) -> withResourceName ( 'memberTagMember' ) -> respond ( ) ; } | Add a MemberTag to the Member . |
30,451 | public static function get ( $ data , $ key , $ default = null ) { if ( self :: isArrayAccess ( $ data ) ) { return self :: getArray ( $ data , $ key , $ default ) ; } if ( is_object ( $ data ) ) { return self :: getObj ( $ data , $ key , $ default ) ; } return $ default ; } | get value from an array or an object . |
30,452 | protected function setColumns ( ) { $ this -> addCheckableColumn ( ) ; $ this -> columns [ 'id' ] = array ( 'label' => 'ID' , 'sortable' => true , 'table_column' => 'users.id' , ) ; $ this -> columns [ 'username' ] = array ( 'label' => 'Username' , 'sortable' => true , 'table_column' => 'users.username' , ) ; $ this -> columns [ 'email' ] = array ( 'label' => 'Email' , 'sortable' => true , 'classes' => 'some_class some_class2' , 'table_column' => 'users.email' , 'thead_attr' => 'style="width:200px" data-some-attr="example"' , ) ; $ this -> columns [ 'created_at' ] = array ( 'label' => 'Created At' , 'sortable' => true , 'table_column' => 'users.created_at' , ) ; $ this -> addActionColumn ( ) ; } | Set columns to display |
30,453 | public function getBlock ( ) { return implode ( "\n " , array_map ( function ( $ line ) { return trim ( trim ( $ line , "*" ) , "/" ) ; } , explode ( "\n" , $ this -> block ) ) ) ; } | get DocBlock without comment tokens |
30,454 | private function sanitize ( $ rawBlock ) { return array_map ( function ( $ line ) { return preg_replace ( '!\s+!' , ' ' , trim ( ltrim ( $ line , "*" ) ) ) ; } , explode ( "\n" , trim ( trim ( trim ( $ rawBlock , "/**" ) , "*/" ) ) ) ) ; } | Break up and clean up DocBlock |
30,455 | public static function track ( $ name , $ dimensions = array ( ) ) { $ name = trim ( $ name ) ; if ( strlen ( $ name ) === 0 ) { throw new Exception ( 'A name for the custom event must be provided.' ) ; } foreach ( $ dimensions as $ key => $ value ) { if ( ! is_string ( $ key ) || ! is_string ( $ value ) ) { throw new Exception ( 'Dimensions expected string keys and values.' ) ; } } return AVClient :: _request ( 'POST' , '/events/' . $ name , null , static :: _toSaveJSON ( $ dimensions ) ) ; } | Tracks the occurrence of a custom event with additional dimensions . Avos will store a data point at the time of invocation with the given event name . |
30,456 | public function get ( $ url ) { $ reporting = error_reporting ( 0 ) ; $ context = $ this -> _createContext ( ) ; $ contents = file_get_contents ( $ url , false , $ context ) ; error_reporting ( $ reporting ) ; if ( $ contents === false ) { $ code = isset ( $ http_response_header [ 0 ] ) ? $ this -> _extractHttpCode ( $ http_response_header [ 0 ] ) : $ this -> _defaultCode ; throw new Exception ( $ url , $ code ) ; } return $ contents ; } | Retrieves contents from the given URL . |
30,457 | protected function _extractHttpCode ( $ header ) { preg_match ( '#^HTTP/[0-9\.]+\s(?P<code>[0-9]+)#i' , $ header , $ matches ) ; return isset ( $ matches [ 'code' ] ) ? $ matches [ 'code' ] : $ this -> _defaultCode ; } | Extracts an HTTP code from the given response header . |
30,458 | public function is_phone ( $ type = null ) { if ( ! \ is_null ( $ type ) ) { r_cast :: array ( $ type ) ; foreach ( $ type as $ k => $ v ) { if ( \ is_string ( $ type [ $ k ] ) ) { $ type [ $ k ] = \ strtolower ( $ type [ $ k ] ) ; } if ( ! $ type [ $ k ] ) { unset ( $ type [ $ k ] ) ; } } if ( ! \ count ( $ type ) ) { $ type = null ; } } return ( ( false !== $ this -> phone ) && ( \ is_null ( $ type ) || \ count ( \ array_intersect ( $ type , $ this -> phone [ 'types' ] ) ) ) ) ; } | Is Phone Valid? |
30,459 | public static function sanitize_phone ( & $ phone = '' ) { r_cast :: string ( $ phone , true ) ; $ from = \ array_keys ( constants :: NUMBER_CHARS ) ; $ to = \ array_values ( constants :: NUMBER_CHARS ) ; $ phone = \ str_replace ( $ from , $ to , $ phone ) ; $ phone = \ preg_replace ( '/[^\d]/' , '' , $ phone ) ; if ( ! c_data :: length_in_range ( $ phone , static :: MIN_LENGTH , static :: MAX_LENGTH ) ) { $ phone = false ; } return true ; } | Sanitize Phone Number |
30,460 | private function addHeader ( ) { $ auth = '<NS1:Security xmlns:NS1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><NS2:Timestamp xmlns:NS2="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">' . date ( 'Y-m-d\TH:i:s.811P' ) . '</Created><Expires xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">' . date ( 'Y-m-d\TH:i:s.811P' , time ( ) + ( 5 * 60 ) ) . '</Expires></NS2:Timestamp><NS1:UsernameToken><Username xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">' . $ this -> login . '</Username><Password xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">' . $ this -> password . '</Password></NS1:UsernameToken></NS1:Security>' ; $ authvalues = new \ SoapVar ( $ auth , XSD_ANYXML ) ; $ header = new \ SoapHeader ( "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" , "Security" , $ authvalues , true ) ; $ this -> getSoap ( ) -> __setSoapHeaders ( $ header ) ; } | Adding of auth header |
30,461 | protected function getSoap ( ) { if ( $ this -> SOAPClient === null ) { $ this -> SOAPClient = new \ SoapClient ( $ this -> url , [ 'trace' => 1 , 'cache_wsdl' => WSDL_CACHE_NONE ] ) ; if ( $ this -> location ) { $ this -> SOAPClient -> __setLocation ( $ this -> location ) ; } } return $ this -> SOAPClient ; } | Get SOAP object |
30,462 | public function getNotification ( ) { $ result = false ; try { $ this -> addHeader ( ) ; $ connectionResult = $ this -> getSoap ( ) -> GetNotification ( [ 'connectionId' => $ this -> connectioId ] ) ; $ result = $ connectionResult -> GetNotificationResult -> EmployeePassageNotifications -> EmployeePassageNotification ; } catch ( \ SoapFault $ ex ) { $ result = false ; } catch ( \ Exception $ ex ) { } return $ result ; } | Long polling request |
30,463 | public function updateEmployee ( $ id , $ firstName , $ lastName , $ secondName = '' ) { $ result = false ; $ this -> addHeader ( ) ; try { $ data = new \ stdClass ( ) ; $ data -> id = $ id ; $ data -> data = new \ stdClass ( ) ; $ data -> data -> FirstName = $ firstName ; $ data -> data -> LastName = $ lastName ; $ data -> data -> SecondName = $ secondName ; $ data -> data -> ModificationDateTime = date ( 'Y-m-d\TH:i:s.811P' ) ; $ this -> getSoap ( ) -> SaveAcsEmployee ( $ data ) ; $ result = true ; } catch ( \ SoapFault $ ex ) { $ this -> logError ( ) ; } return $ result ; } | Update employee s info |
30,464 | public function setKeyIsLost ( $ cardNumber , $ employeeId , $ index = 1 ) { $ result = false ; $ cardNumber = $ this -> prepareKey ( $ cardNumber ) ; $ this -> addHeader ( ) ; try { $ result = $ this -> getSoap ( ) -> SetStatusOfAcsKeyAsLost ( [ 'keyNumber' => $ cardNumber , 'indexNumber' => $ index , 'employeeID' => $ employeeId ] ) ; } catch ( \ SoapFault $ ex ) { $ this -> logError ( ) ; } return $ result ; } | Sets key s status |
30,465 | public function getEmployeeIdByKey ( $ cardNumber ) { $ cardNumber = $ this -> prepareKey ( $ cardNumber ) ; $ result = null ; $ this -> addHeader ( ) ; try { $ soapResult = $ this -> getSoap ( ) -> GetAssignedAcsKeyByKeyNumber ( [ 'keyNumber' => $ cardNumber ] ) ; if ( isset ( $ soapResult -> GetAssignedAcsKeyByKeyNumberResult -> AcsEmployeeId ) ) { $ result = $ soapResult -> GetAssignedAcsKeyByKeyNumberResult -> AcsEmployeeId ; } } catch ( \ SoapFault $ ex ) { $ this -> logError ( ) ; } return $ result ; } | Returnes employees s id by card number |
30,466 | public function removeEmployeeByCardNumber ( $ cardNumber ) { $ cardNumber = $ this -> prepareKey ( $ cardNumber ) ; $ result = null ; $ this -> addHeader ( ) ; try { $ empResult = $ this -> getSoap ( ) -> GetAssignedAcsKeyByKeyNumber ( [ 'keyNumber' => $ cardNumber ] ) ; if ( $ empResult -> GetAssignedAcsKeyByKeyNumberResult !== null ) { $ result = $ this -> removeEmployee ( $ empResult -> GetAssignedAcsKeyByKeyNumberResult -> AcsEmployeeId ) ; } } catch ( \ SoapFault $ ex ) { $ this -> logError ( ) ; } return $ result ; } | Removing employee by card number |
30,467 | public function getGroups ( ) { $ result = [ ] ; $ this -> addHeader ( ) ; try { $ rawGroups = $ this -> getSoap ( ) -> GetAcsEmployeeGroups ( ) -> GetAcsEmployeeGroupsResult ; if ( isset ( $ rawGroups -> AcsEmployeeGroup ) && is_array ( $ rawGroups -> AcsEmployeeGroup ) ) { $ rawGroups = $ rawGroups -> AcsEmployeeGroup ; } foreach ( $ rawGroups as $ group ) { $ result [ ] = new EmployeeGroup ( ( array ) $ group ) ; } } catch ( \ SoapFault $ ex ) { $ this -> logError ( ) ; } return $ result ; } | Get group list |
30,468 | public function addEmployeePhoto ( $ employeeId , $ index , $ base64Data ) { $ result = false ; $ indexes = [ 1 , 2 ] ; $ freeIndex = 0 ; if ( $ index === null ) { foreach ( $ indexes as $ index ) { if ( ( $ photoInfo = $ this -> getEmployeePhoto ( $ employeeId , $ index ) ) !== false && ( ! isset ( $ photoInfo -> GetAcsEmployeePhotoResult ) || $ photoInfo -> GetAcsEmployeePhotoResult == null ) ) { $ freeIndex = $ index ; break ; } } } else { $ freeIndex = $ index ; } if ( $ freeIndex > 0 ) { $ this -> addHeader ( ) ; try { $ result = $ this -> getSoap ( ) -> SetAcsEmployeePhoto ( [ 'employeeId' => $ employeeId , 'photoNumber' => $ freeIndex , 'data' => $ base64Data ] ) ; } catch ( \ SoapFault $ ex ) { $ result = false ; $ this -> logError ( ) ; } } return $ result ; } | Addes photo to employee s profile |
30,469 | public function getEmployeePhoto ( $ employeeId , $ index ) { $ this -> addHeader ( ) ; try { $ result = $ this -> getSoap ( ) -> GetAcsEmployeePhoto ( [ 'employeeId' => $ employeeId , 'photoNumber' => $ index ] ) ; } catch ( \ SoapFault $ ex ) { $ result = false ; $ this -> logError ( ) ; } return $ result ; } | Get employee s photo by index |
30,470 | public static function get ( $ request , $ match ) { if ( isset ( $ match [ 'userId' ] ) ) { $ user = Pluf_Shortcuts_GetObjectOr404 ( 'User_Account' , $ match [ 'userId' ] ) ; } else { $ user = $ request -> user ; } if ( array_key_exists ( 'profileId' , $ match ) ) { return Pluf_Shortcuts_GetObjectOr404 ( 'User_Profile' , $ match [ 'profileId' ] ) ; } $ profile = self :: getProfileOfUser ( $ user ) ; if ( $ profile === null ) { $ profile = new User_Profile ( ) ; $ profile -> account_id = $ user ; } return $ profile ; } | Returns profile information of specified user . In this server each account has at most one profile . |
30,471 | public static function getProfileOfUser ( $ user ) { $ profiles = $ user -> get_profiles_list ( ) ; if ( count ( $ profiles ) === 0 || $ profiles [ 0 ] -> isAnonymous ( ) ) { return null ; } else { return $ profiles [ 0 ] ; } } | Returns profile of given user . If no profile is created for given user returns null . |
30,472 | public static function update ( $ request , $ match ) { if ( isset ( $ match [ 'userId' ] ) ) { $ user = Pluf_Shortcuts_GetObjectOr404 ( 'User_Account' , $ match [ 'userId' ] ) ; } else { $ user = $ request -> user ; } $ profile = null ; if ( array_key_exists ( 'profileId' , $ match ) ) { $ profile = Pluf_Shortcuts_GetObjectOr404 ( 'User_Profile' , $ match [ 'profileId' ] ) ; if ( $ profile -> account_id !== $ user -> id ) { throw new Pluf_HTTP_Error404 ( 'You are not allowed to change this profile.' ) ; } $ form = Pluf_Shortcuts_GetFormForUpdateModel ( $ profile , $ request -> REQUEST , array ( ) ) ; $ profile = $ form -> save ( ) ; } else { $ profile = self :: getProfileOfUser ( $ user ) ; if ( $ profile === null ) { $ profile = new User_Profile ( ) ; $ profile -> account_id = $ user ; $ form = Pluf_Shortcuts_GetFormForModel ( $ profile , $ request -> REQUEST , array ( ) ) ; $ profile = $ form -> save ( ) ; } else { $ form = Pluf_Shortcuts_GetFormForUpdateModel ( $ profile , $ request -> REQUEST , array ( ) ) ; $ profile = $ form -> save ( ) ; } } return $ profile ; } | Update profile of specified user . In this server each user has at most one profile . |
30,473 | public static function delete ( $ request , $ match ) { if ( isset ( $ match [ 'userId' ] ) ) { $ user = Pluf_Shortcuts_GetObjectOr404 ( 'User_Account' , $ match [ 'userId' ] ) ; } else { $ user = $ request -> user ; } $ profile = null ; if ( array_key_exists ( 'profileId' , $ match ) ) { $ profile = Pluf_Shortcuts_GetObjectOr404 ( 'User_Profile' , $ match [ 'profileId' ] ) ; if ( $ profile -> account_id !== $ user -> id ) { throw new Pluf_HTTP_Error404 ( 'Profile is not blong to given user' ) ; } } else { $ profile = self :: getProfileOfUser ( $ user ) ; if ( $ profile === null ) { return new User_Profile ( ) ; } } $ profile -> delete ( ) ; return $ profile ; } | Deletes profile of specified user . |
30,474 | public function set ( $ name , $ value , $ deleteCookie = false ) { $ attributeValueList = [ ] ; if ( $ this -> cookieOptions [ 'Secure' ] ) { $ attributeValueList [ ] = 'Secure' ; } if ( $ this -> cookieOptions [ 'HttpOnly' ] ) { $ attributeValueList [ ] = 'HttpOnly' ; } if ( null !== $ this -> cookieOptions [ 'Path' ] ) { $ attributeValueList [ ] = \ sprintf ( 'Path=%s' , $ this -> cookieOptions [ 'Path' ] ) ; } if ( null !== $ this -> cookieOptions [ 'Domain' ] ) { $ attributeValueList [ ] = \ sprintf ( 'Domain=%s' , $ this -> cookieOptions [ 'Domain' ] ) ; } if ( null !== $ this -> cookieOptions [ 'Max-Age' ] && ! $ deleteCookie ) { $ attributeValueList [ ] = \ sprintf ( 'Max-Age=%d' , $ this -> cookieOptions [ 'Max-Age' ] ) ; } if ( $ deleteCookie ) { $ attributeValueList [ ] = 'Max-Age=0' ; } if ( null !== $ this -> cookieOptions [ 'SameSite' ] ) { $ attributeValueList [ ] = \ sprintf ( 'SameSite=%s' , $ this -> cookieOptions [ 'SameSite' ] ) ; } $ this -> header -> set ( \ sprintf ( 'Set-Cookie: %s=%s; %s' , $ name , $ value , \ implode ( '; ' , $ attributeValueList ) ) , false ) ; } | Set a cookie value . |
30,475 | public function replace ( $ name , $ value ) { $ cookieList = [ ] ; foreach ( $ this -> header -> ls ( ) as $ hdr ) { if ( 0 === \ stripos ( $ hdr , 'Set-Cookie: ' ) ) { if ( 0 !== \ stripos ( $ hdr , \ sprintf ( 'Set-Cookie: %s=' , $ name ) ) ) { $ cookieList [ ] = $ hdr ; } } } $ this -> header -> remove ( 'Set-Cookie' ) ; foreach ( $ cookieList as $ cookie ) { $ this -> header -> set ( $ cookie , false ) ; } $ this -> set ( $ name , $ value ) ; } | Replace an existing cookie . |
30,476 | public function getDirs ( $ path = '' ) { $ dirpath = str_replace ( '\\' , '/' , $ this -> config [ 'upload_path' ] . '/' . str_replace ( $ this -> config [ 'upload_path' ] , '' , $ path ) ) ; $ data = $ this -> obj -> getDirs ( $ dirpath ) ; foreach ( $ data as $ k => $ v ) { $ v = str_replace ( array ( $ this -> config [ 'upload_path' ] , '\\' ) , array ( '' , '/' ) , $ v ) ; $ data [ $ k ] = array ( 'path' => $ v , 'val' => $ v ) ; } if ( empty ( $ data ) ) { $ data [ 0 ] = array ( 'path' => $ path , 'val' => $ path ) ; } return $ data ; } | get all sub dirs |
30,477 | public function deleteThumbs ( array $ routes ) { $ basePath = Yii :: getAlias ( $ routes [ 'basePath' ] ) ; foreach ( $ this -> getThumbs ( ) as $ thumbUrl ) { unlink ( "$basePath/$thumbUrl" ) ; } unlink ( "$basePath/{$this->getDefaultThumbUrl()}" ) ; } | Delete thumbnails for current image |
30,478 | protected function validateUsername ( $ attribute , $ value , $ parameters ) { $ pattern = ! empty ( $ parameters [ 0 ] ) ? $ parameters [ 0 ] : '/^([a-zA-Z0-9._-])+$/i' ; return ( bool ) preg_match ( $ pattern , $ value ) ; } | Validate that attribute is a valid username . |
30,479 | public function getHeaders ( ) { if ( ! isset ( $ this -> properties [ MessageProperties :: KEY_HEADERS ] ) ) { $ this -> properties [ MessageProperties :: KEY_HEADERS ] = [ ] ; } return $ this -> properties [ MessageProperties :: KEY_HEADERS ] ; } | Get the headers of the message . |
30,480 | public static function randColor ( ) { $ c = '#' ; $ i = 0 ; while ( $ i ++ < 3 ) { $ c .= str_pad ( dechex ( mt_rand ( 0 , 255 ) ) , 2 , '0' , STR_PAD_LEFT ) ; } return $ c ; } | Returns a random color . |
30,481 | public static function get ( $ config = array ( ) ) { $ hash = md5 ( serialize ( $ config ) ) ; if ( ! isset ( self :: $ _instances [ $ hash ] ) ) self :: $ _instances [ $ hash ] = new static ( $ config ) ; return self :: $ _instances [ $ hash ] ; } | Return instance of class . |
30,482 | public function publishFolder ( $ path ) { $ newName = dirname ( $ _SERVER [ 'SCRIPT_FILENAME' ] ) . DIRECTORY_SEPARATOR . $ this -> publishFolder . DIRECTORY_SEPARATOR . md5 ( $ path ) ; $ url = \ mpf \ WebApp :: get ( ) -> request ( ) -> getWebRoot ( ) . $ this -> publishFolder . "/" . md5 ( $ path ) . "/" ; if ( $ this -> _isPublished ( $ newName ) ) return $ url ; $ this -> _folder ( $ path , $ newName ) ; $ this -> publishCache [ $ newName ] = true ; return $ url ; } | Publish an entire folder |
30,483 | public function publishFile ( $ path ) { $ newName = dirname ( SCRIPT_FILENAME ) . DIRECTORY_SEPARATOR . $ this -> publishFolder . DIRECTORY_SEPARATOR . "files" . DIRECTORY_SEPARATOR . md5 ( $ path ) . '_' . basename ( $ path ) ; $ url = \ mpf \ WebApp :: get ( ) -> request ( ) -> getWebRoot ( ) . $ this -> publishFolder . "/files/" . md5 ( $ path ) . '_' . basename ( $ path ) ; if ( $ this -> _isPublished ( $ newName ) ) return $ newName ; $ this -> _file ( $ path , $ newName ) ; $ this -> publishCache [ $ newName ] = true ; return $ url ; } | Publish a single file |
30,484 | private function _isPublished ( $ publishPath ) { if ( isset ( $ this -> publishCache [ $ publishPath ] ) && $ this -> publishCache [ $ publishPath ] ) return true ; if ( $ this -> developmentMode ) { return false ; } return $ this -> publishCache [ $ publishPath ] = file_exists ( $ publishPath ) ; } | Check if selected path was already published |
30,485 | protected function _folder ( $ oldPath , $ newPath ) { if ( ! is_dir ( $ newPath ) ) { $ oldumask = umask ( 0 ) ; mkdir ( $ newPath , 01777 ) ; umask ( $ oldumask ) ; } elseif ( filemtime ( $ oldPath ) < filemtime ( $ newPath ) ) { return ; } else { } $ dir = @ opendir ( $ oldPath ) or trigger_error ( "Unable to open original folder to copy it! ($oldPath)" ) ; while ( $ file = readdir ( $ dir ) ) { if ( $ file != "." && $ file != ".." && ! is_dir ( "$oldPath/$file" ) ) { copy ( "$oldPath/$file" , "$newPath/$file" ) ; } elseif ( $ file != "." && $ file != ".." ) { $ this -> _folder ( "$oldPath/$file" , "$newPath/$file" ) ; } } closedir ( $ dir ) ; } | Copy folder contents from one location to another |
30,486 | public function update ( $ key , $ value , $ namespace , $ lifetime = null , $ userdata = null ) { $ key = $ this -> calculateUuid ( $ key . $ namespace ) ; $ dataset = array ( $ this -> getExpiresAbsolute ( $ lifetime ) , $ userdata , $ this -> encode ( $ value ) , $ namespace , ) ; if ( true !== $ result = $ this -> connection -> replace ( $ key , $ dataset , ( $ this -> getCompress ( ) === true ) ? MEMCACHE_COMPRESSED : 0 , $ this -> getExpiresAbsolute ( $ lifetime ) ) ) { throw new Doozr_Cache_Service_Exception ( 'Error while updating dataset!' ) ; } if ( $ result === true ) { $ this -> addToRuntimeCache ( $ key , $ dataset , $ namespace ) ; } return true ; } | Updates data in cache . |
30,487 | public function exists ( $ key , $ namespace ) { $ key = $ this -> calculateUuid ( $ key . $ namespace ) ; $ result = false ; if ( $ this -> getFromRuntimeCache ( $ key , $ namespace ) !== false ) { $ result = true ; } else { $ value = $ this -> connection -> get ( $ key ) ; if ( $ value !== false ) { $ this -> addToRuntimeCache ( $ key , $ value , $ namespace ) ; $ result = true ; } } return $ result ; } | Checks if a dataset exists |
30,488 | public function garbageCollection ( $ namespace , $ lifetime ) { $ result = true ; if ( $ this -> getConnection ( ) !== null ) { $ result = $ this -> doGarbageCollection ( $ namespace , $ lifetime ) ; } return $ result ; } | deletes all expired files |
30,489 | protected function connect ( $ hostname , $ port ) { $ memcache = new Memcached ( ) ; $ memcache -> addServer ( $ hostname , $ port ) ; try { @ $ memcache -> connect ( $ hostname , $ port ) ; } catch ( Exception $ e ) { throw new Doozr_Cache_Service_Exception ( sprintf ( 'Error while connecting to host: "%s" on Port: "%s". Connection failed.' , $ hostname , $ port ) ) ; } return $ memcache ; } | Connects to a server . |
30,490 | protected function createResponseBody ( \ Throwable $ exception ) : string { if ( file_exists ( $ this -> projectPath . '/docroot/500.html' ) ) { return file_get_contents ( $ this -> projectPath . '/docroot/500.html' ) ; } return "I'm sorry but I can not fulfill your request. Somewhere someone messed something up." ; } | creates response body with useful data for display |
30,491 | public static function getInstance ( ) { self :: $ strict = false ; $ arguments = func_get_args ( ) ; if ( empty ( $ arguments ) ) { $ instance = parent :: getInstance ( ) ; } else { $ instance = parent :: getInstance ( $ arguments ) ; } return $ instance ; } | Constructor for singleton pattern . |
30,492 | public function dumpParameters ( ) { $ parameters = [ ] ; foreach ( $ this -> getParameters ( ) as $ parameter ) { $ string = '' ; if ( $ parameter -> isArray ( ) ) { $ string .= 'array ' ; } elseif ( $ parameter -> getClass ( ) ) { $ string .= $ parameter -> getClass ( ) -> name . ' ' ; } if ( $ parameter -> isPassedByReference ( ) ) { $ string .= '&' ; } $ string .= '$' . $ parameter -> name ; if ( $ parameter -> isOptional ( ) ) { $ string .= ' = ' . var_export ( $ parameter -> getDefaultValue ( ) , true ) ; } $ parameters [ ] = $ string ; } return '(' . implode ( ', ' , $ parameters ) . ')' ; } | Dump function parameters as a PHP tupple . |
30,493 | public function dumpBody ( ) { $ lines = file ( $ this -> getFileName ( ) ) ; $ startLine = $ this -> getStartLine ( ) ; $ endLine = $ this -> getEndLine ( ) ; $ lines [ $ startLine - 1 ] = explode ( '{' , $ lines [ $ startLine - 1 ] ) ; $ lines [ $ startLine - 1 ] = end ( $ lines [ $ startLine - 1 ] ) ; $ end = mb_strrpos ( $ lines [ $ endLine - 1 ] , '}' ) ; if ( $ end !== false ) { $ lines [ $ endLine - 1 ] = mb_substr ( $ lines [ $ endLine - 1 ] , 0 , $ end ) ; } $ lines [ $ endLine - 1 ] .= '}' ; $ code = '' ; for ( $ line = $ startLine - 1 ; $ line < $ endLine ; $ line ++ ) { $ code .= $ lines [ $ line ] ; } return $ code ; } | Dump function body contained inside brackets . |
30,494 | public function translate ( $ locale = null ) { if ( ! $ locale ) { $ locale = \ localizer \ locale ( ) -> id ( ) ; } else { $ locale = ( int ) $ locale ; } return $ this -> getTranslation ( $ locale ) ; } | Get translation for specified|default|fallback locale |
30,495 | protected function getTranslationByLocaleKey ( $ key ) { foreach ( $ this -> cachedTranslations ( ) as $ translation ) { if ( ( int ) $ translation -> getAttribute ( $ this -> getLocaleKey ( ) ) === ( int ) $ key ) { return $ translation ; } } return null ; } | Find a translation by loale |
30,496 | protected function getTranslationOrNew ( $ locale ) { if ( ( $ translation = $ this -> getTranslation ( $ locale ) ) === null ) { $ translation = $ this -> createNewTranslation ( $ locale ) ; } return $ translation ; } | Get translation or create new if not exists |
30,497 | public function hasTranslation ( $ locale = null ) { $ locale = $ locale ? : \ localizer \ locale ( ) -> id ( ) ; foreach ( $ this -> cachedTranslations ( ) as $ translation ) { if ( ( int ) $ translation -> getAttribute ( $ this -> getLocaleKey ( ) ) === ( int ) $ locale ) { return true ; } } return false ; } | Check if translation exists |
30,498 | public function getAttribute ( $ key ) { if ( $ this -> isKeyReturningTranslationText ( $ key ) ) { if ( $ translation = $ this -> getTranslation ( ) ) { return $ translation -> $ key ; } if ( $ translation = $ this -> getTranslation ( \ localizer \ getDefault ( ) -> id ( ) ) ) { return $ translation -> $ key ; } return null ; } return parent :: getAttribute ( $ key ) ; } | Translatable attribute accessor |
30,499 | public function setAttribute ( $ key , $ value ) { if ( $ this -> hasTranslatedAttributes ( ) && in_array ( $ key , $ this -> translatedAttributes ) ) { $ this -> getTranslationOrNew ( \ localizer \ locale ( ) -> id ( ) ) -> $ key = $ value ; } else { parent :: setAttribute ( $ key , $ value ) ; } } | Translatable attribute mutator |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.