@@ -8,8 +8,8 @@ |
||
| 8 | 8 | |
| 9 | 9 | namespace Ext\Serializer; |
| 10 | 10 | |
| 11 | -use Ext\Serializable; |
|
| 12 | -use Ext\SerializableObject; |
|
| 11 | +use Ext\Serializable; |
|
| 12 | +use Ext\SerializableObject; |
|
| 13 | 13 | use Ext\Serializer; |
| 14 | 14 | |
| 15 | 15 | class ArraySerializer implements Serializer |
@@ -15,70 +15,70 @@ |
||
| 15 | 15 | class ArraySerializer implements Serializer |
| 16 | 16 | {
|
| 17 | 17 | |
| 18 | - protected $resolver; |
|
| 18 | + protected $resolver; |
|
| 19 | 19 | |
| 20 | - public function serialize(SerializableObject $object) |
|
| 21 | - {
|
|
| 22 | - return $this->serializeValue($object); |
|
| 23 | - } |
|
| 20 | + public function serialize(SerializableObject $object) |
|
| 21 | + {
|
|
| 22 | + return $this->serializeValue($object); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @return ExtResolver |
|
| 27 | - */ |
|
| 28 | - protected function getResolver(){
|
|
| 29 | - if(!$this->resolver){
|
|
| 30 | - $this->setResolver(new ExtResolver()); |
|
| 31 | - } |
|
| 32 | - return $this->resolver; |
|
| 33 | - } |
|
| 25 | + /** |
|
| 26 | + * @return ExtResolver |
|
| 27 | + */ |
|
| 28 | + protected function getResolver(){
|
|
| 29 | + if(!$this->resolver){
|
|
| 30 | + $this->setResolver(new ExtResolver()); |
|
| 31 | + } |
|
| 32 | + return $this->resolver; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - public function setResolver(ExtResolver $resolver){
|
|
| 36 | - $this->resolver = $resolver; |
|
| 37 | - } |
|
| 35 | + public function setResolver(ExtResolver $resolver){
|
|
| 36 | + $this->resolver = $resolver; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - protected function serializeAssociativeArray($array) {
|
|
| 40 | - if($array instanceof Serializable){
|
|
| 41 | - $type = $this->getResolver()->resolve($array); |
|
| 42 | - $array = $array->properties(); |
|
| 43 | - if($type){
|
|
| 44 | - $array = $type + $array; |
|
| 45 | - } |
|
| 46 | - } |
|
| 39 | + protected function serializeAssociativeArray($array) {
|
|
| 40 | + if($array instanceof Serializable){
|
|
| 41 | + $type = $this->getResolver()->resolve($array); |
|
| 42 | + $array = $array->properties(); |
|
| 43 | + if($type){
|
|
| 44 | + $array = $type + $array; |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - if(!$array) return new \stdClass(); |
|
| 48 | + if(!$array) return new \stdClass(); |
|
| 49 | 49 | |
| 50 | - $serialized = array(); |
|
| 51 | - foreach ($array as $key => $value) {
|
|
| 52 | - $serialized[$key] = $this->serializeValue($value); |
|
| 53 | - } |
|
| 50 | + $serialized = array(); |
|
| 51 | + foreach ($array as $key => $value) {
|
|
| 52 | + $serialized[$key] = $this->serializeValue($value); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - return $serialized; |
|
| 56 | - } |
|
| 55 | + return $serialized; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - protected function serializeArray(array $array) {
|
|
| 59 | - $out = array(); |
|
| 58 | + protected function serializeArray(array $array) {
|
|
| 59 | + $out = array(); |
|
| 60 | 60 | |
| 61 | - foreach($array as $e){
|
|
| 62 | - $out[] = $this->serializeValue($e); |
|
| 63 | - } |
|
| 64 | - return $out; |
|
| 65 | - } |
|
| 61 | + foreach($array as $e){
|
|
| 62 | + $out[] = $this->serializeValue($e); |
|
| 63 | + } |
|
| 64 | + return $out; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - protected function isAssociativeArray(array $array) {
|
|
| 68 | - return (bool)count(array_filter(array_keys($array), 'is_string')); |
|
| 69 | - } |
|
| 67 | + protected function isAssociativeArray(array $array) {
|
|
| 68 | + return (bool)count(array_filter(array_keys($array), 'is_string')); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - protected function serializeValue($value) {
|
|
| 72 | - if($value instanceof Serializable){
|
|
| 73 | - return $this->serializeAssociativeArray($value); |
|
| 74 | - } elseif(is_array($value)) {
|
|
| 75 | - if ($this->isAssociativeArray($value) || empty($value)) {
|
|
| 76 | - return $this->serializeAssociativeArray($value); |
|
| 77 | - } else {
|
|
| 78 | - return $this->serializeArray($value); |
|
| 79 | - } |
|
| 80 | - }else{
|
|
| 81 | - return $value; |
|
| 82 | - } |
|
| 83 | - } |
|
| 71 | + protected function serializeValue($value) {
|
|
| 72 | + if($value instanceof Serializable){
|
|
| 73 | + return $this->serializeAssociativeArray($value); |
|
| 74 | + } elseif(is_array($value)) {
|
|
| 75 | + if ($this->isAssociativeArray($value) || empty($value)) {
|
|
| 76 | + return $this->serializeAssociativeArray($value); |
|
| 77 | + } else {
|
|
| 78 | + return $this->serializeArray($value); |
|
| 79 | + } |
|
| 80 | + }else{
|
|
| 81 | + return $value; |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | 84 | } |
| 85 | 85 | \ No newline at end of file |
@@ -25,27 +25,27 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * @return ExtResolver |
| 27 | 27 | */ |
| 28 | - protected function getResolver(){
|
|
| 29 | - if(!$this->resolver){
|
|
| 28 | + protected function getResolver() {
|
|
| 29 | + if (!$this->resolver) {
|
|
| 30 | 30 | $this->setResolver(new ExtResolver()); |
| 31 | 31 | } |
| 32 | 32 | return $this->resolver; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public function setResolver(ExtResolver $resolver){
|
|
| 35 | + public function setResolver(ExtResolver $resolver) {
|
|
| 36 | 36 | $this->resolver = $resolver; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | protected function serializeAssociativeArray($array) {
|
| 40 | - if($array instanceof Serializable){
|
|
| 40 | + if ($array instanceof Serializable) {
|
|
| 41 | 41 | $type = $this->getResolver()->resolve($array); |
| 42 | 42 | $array = $array->properties(); |
| 43 | - if($type){
|
|
| 44 | - $array = $type + $array; |
|
| 43 | + if ($type) {
|
|
| 44 | + $array = $type+$array; |
|
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if(!$array) return new \stdClass(); |
|
| 48 | + if (!$array) return new \stdClass(); |
|
| 49 | 49 | |
| 50 | 50 | $serialized = array(); |
| 51 | 51 | foreach ($array as $key => $value) {
|
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | protected function serializeArray(array $array) {
|
| 59 | 59 | $out = array(); |
| 60 | 60 | |
| 61 | - foreach($array as $e){
|
|
| 61 | + foreach ($array as $e) {
|
|
| 62 | 62 | $out[] = $this->serializeValue($e); |
| 63 | 63 | } |
| 64 | 64 | return $out; |
@@ -69,15 +69,15 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | protected function serializeValue($value) {
|
| 72 | - if($value instanceof Serializable){
|
|
| 72 | + if ($value instanceof Serializable) {
|
|
| 73 | 73 | return $this->serializeAssociativeArray($value); |
| 74 | - } elseif(is_array($value)) {
|
|
| 74 | + } elseif (is_array($value)) {
|
|
| 75 | 75 | if ($this->isAssociativeArray($value) || empty($value)) {
|
| 76 | 76 | return $this->serializeAssociativeArray($value); |
| 77 | - } else {
|
|
| 77 | + }else {
|
|
| 78 | 78 | return $this->serializeArray($value); |
| 79 | 79 | } |
| 80 | - }else{
|
|
| 80 | + }else {
|
|
| 81 | 81 | return $value; |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -45,7 +45,9 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if(!$array) return new \stdClass(); |
|
| 48 | + if(!$array) {
|
|
| 49 | + return new \stdClass(); |
|
| 50 | + } |
|
| 49 | 51 | |
| 50 | 52 | $serialized = array(); |
| 51 | 53 | foreach ($array as $key => $value) {
|
@@ -77,7 +79,7 @@ discard block |
||
| 77 | 79 | } else {
|
| 78 | 80 | return $this->serializeArray($value); |
| 79 | 81 | } |
| 80 | - }else{
|
|
| 82 | + } else{
|
|
| 81 | 83 | return $value; |
| 82 | 84 | } |
| 83 | 85 | } |
@@ -59,10 +59,10 @@ |
||
| 59 | 59 | '\Ext\Data\Proxy\Ajax' => ['type'=>'ajax'], |
| 60 | 60 | '\Ext\Data\Proxy\Server' => ['type'=>'server'] |
| 61 | 61 | ]; |
| 62 | - $readers = [ |
|
| 63 | - '\Ext\Data\Reader\Json' => ['type'=>'json'], |
|
| 64 | - '\Ext\Data\Reader\Reader' => ['type'=>'base'], |
|
| 65 | - ]; |
|
| 62 | + $readers = [ |
|
| 63 | + '\Ext\Data\Reader\Json' => ['type'=>'json'], |
|
| 64 | + '\Ext\Data\Reader\Reader' => ['type'=>'base'], |
|
| 65 | + ]; |
|
| 66 | 66 | $plugins = [ |
| 67 | 67 | '\Ext\Grid\Filters\Filters' => ['ptype'=>'gridfilters'], |
| 68 | 68 | '\Ext\Grid\Filters\Filter\Boolean' => ['type'=>'boolean'], |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | class ExtResolver |
| 10 | 10 | {
|
| 11 | - protected function getResolveArray(){
|
|
| 11 | + protected function getResolveArray() {
|
|
| 12 | 12 | $xtypes = [ |
| 13 | 13 | '\Ext\Grid\Column\Widget' => ['xtype'=>'widgetcolumn'], |
| 14 | 14 | '\Ext\Grid\Column\Template' => ['xtype'=>'templatecolumn'], |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | '\Ext\Container\Container'=>['xtype'=>'container'], |
| 56 | 56 | '\Ext\Component' =>['xtype'=>'component'], |
| 57 | 57 | ]; |
| 58 | - $proxies =[ |
|
| 58 | + $proxies = [ |
|
| 59 | 59 | '\Ext\Data\Proxy\Ajax' => ['type'=>'ajax'], |
| 60 | 60 | '\Ext\Data\Proxy\Server' => ['type'=>'server'] |
| 61 | 61 | ]; |
@@ -75,13 +75,13 @@ discard block |
||
| 75 | 75 | '\Ext\Data\ArrayStore' => ['store'=>'array'], |
| 76 | 76 | '\Ext\Data\Store' => ['store'=>'store'], |
| 77 | 77 | ]; |
| 78 | - return $xtypes+$readers+ $proxies+$plugins+$stores; |
|
| 78 | + return $xtypes+$readers+$proxies+$plugins+$stores; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - public function resolve(Base $component){
|
|
| 82 | - foreach($this->getResolveArray() as $class=>$types){
|
|
| 81 | + public function resolve(Base $component) {
|
|
| 82 | + foreach ($this->getResolveArray() as $class=>$types) {
|
|
| 83 | 83 | |
| 84 | - if(is_a($component,$class)){
|
|
| 84 | + if (is_a($component, $class)) {
|
|
| 85 | 85 | return $types; |
| 86 | 86 | } |
| 87 | 87 | } |
@@ -13,9 +13,9 @@ |
||
| 13 | 13 | |
| 14 | 14 | class ExtSerializer extends ArraySerializer |
| 15 | 15 | {
|
| 16 | - public function serialize(SerializableObject $object) |
|
| 17 | - {
|
|
| 18 | - return json_encode(parent::serialize($object),JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK); |
|
| 19 | - } |
|
| 16 | + public function serialize(SerializableObject $object) |
|
| 17 | + {
|
|
| 18 | + return json_encode(parent::serialize($object),JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | \ No newline at end of file |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | {
|
| 16 | 16 | public function serialize(SerializableObject $object) |
| 17 | 17 | {
|
| 18 | - return json_encode(parent::serialize($object),JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK); |
|
| 18 | + return json_encode(parent::serialize($object), JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | \ No newline at end of file |
@@ -13,8 +13,8 @@ |
||
| 13 | 13 | {
|
| 14 | 14 | |
| 15 | 15 | |
| 16 | - public static function create($class,array $config=array()){
|
|
| 17 | - $class = '\\'.str_replace('.','\\',$class);
|
|
| 16 | + public static function create($class, array $config = array()) {
|
|
| 17 | + $class = '\\'.str_replace('.', '\\', $class);
|
|
| 18 | 18 | return new $class($config); |
| 19 | 19 | } |
| 20 | 20 | } |
| 21 | 21 | \ No newline at end of file |
@@ -5,11 +5,11 @@ |
||
| 5 | 5 | class Enum extends SingleFilter |
| 6 | 6 | {
|
| 7 | 7 | |
| 8 | - public function setOptions(array $options){
|
|
| 9 | - return $this->setProperty('options',$options);
|
|
| 8 | + public function setOptions(array $options) {
|
|
| 9 | + return $this->setProperty('options', $options);
|
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | - public function getOptions(){
|
|
| 12 | + public function getOptions() {
|
|
| 13 | 13 | return $this->getProperty('options');
|
| 14 | 14 | } |
| 15 | 15 | |
@@ -4,11 +4,11 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Date extends TriFilter |
| 6 | 6 | {
|
| 7 | - public function setDateFormat($dateFormat){
|
|
| 8 | - return $this->setProperty('dateFormat',$dateFormat);
|
|
| 7 | + public function setDateFormat($dateFormat) {
|
|
| 8 | + return $this->setProperty('dateFormat', $dateFormat);
|
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | - public function getDateFormat(){
|
|
| 11 | + public function getDateFormat() {
|
|
| 12 | 12 | return $this->getProperty('dateFormat');
|
| 13 | 13 | } |
| 14 | 14 | |
@@ -4,19 +4,19 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class Base extends \Ext\Plugin\Base |
| 6 | 6 | {
|
| 7 | - public function setDataIndex($dataIndex){
|
|
| 8 | - return $this->setProperty('dataIndex',$dataIndex);
|
|
| 7 | + public function setDataIndex($dataIndex) {
|
|
| 8 | + return $this->setProperty('dataIndex', $dataIndex);
|
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | - public function getDataIndex(){
|
|
| 11 | + public function getDataIndex() {
|
|
| 12 | 12 | return $this->getProperty('dataIndex');
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - public function setValue($value){
|
|
| 16 | - return $this->setProperty('value',$value);
|
|
| 15 | + public function setValue($value) {
|
|
| 16 | + return $this->setProperty('value', $value);
|
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public function getValue(){
|
|
| 19 | + public function getValue() {
|
|
| 20 | 20 | return $this->getProperty('value');
|
| 21 | 21 | } |
| 22 | 22 | |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | * @param $showMenu |
| 26 | 26 | * @return $this |
| 27 | 27 | */ |
| 28 | - public function setShowMenu($showMenu){
|
|
| 29 | - return $this->setProperty('showMenu',(bool)$showMenu);
|
|
| 28 | + public function setShowMenu($showMenu) {
|
|
| 29 | + return $this->setProperty('showMenu', (bool)$showMenu);
|
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - public function getShowMenu(){
|
|
| 32 | + public function getShowMenu() {
|
|
| 33 | 33 | return $this->getProperty('showMenu');
|
| 34 | 34 | } |
| 35 | 35 | |
@@ -4,19 +4,19 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Boolean extends SingleFilter |
| 6 | 6 | {
|
| 7 | - public function setNoText($noText){
|
|
| 8 | - return $this->setProperty('noText',$noText);
|
|
| 7 | + public function setNoText($noText) {
|
|
| 8 | + return $this->setProperty('noText', $noText);
|
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | - public function getNoText(){
|
|
| 11 | + public function getNoText() {
|
|
| 12 | 12 | return $this->getProperty('noText');
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - public function setYesText($yesText){
|
|
| 16 | - return $this->setProperty('yesText',$yesText);
|
|
| 15 | + public function setYesText($yesText) {
|
|
| 16 | + return $this->setProperty('yesText', $yesText);
|
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public function getYesText(){
|
|
| 19 | + public function getYesText() {
|
|
| 20 | 20 | return $this->getProperty('yesText');
|
| 21 | 21 | } |
| 22 | 22 | |
@@ -7,11 +7,11 @@ |
||
| 7 | 7 | class Widget extends Column |
| 8 | 8 | {
|
| 9 | 9 | |
| 10 | - public function setWidget(Component $widget){
|
|
| 11 | - return $this->setProperty('widget',$widget);
|
|
| 10 | + public function setWidget(Component $widget) {
|
|
| 11 | + return $this->setProperty('widget', $widget);
|
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - public function getWidget(){
|
|
| 14 | + public function getWidget() {
|
|
| 15 | 15 | return $this->getProperty('widget');
|
| 16 | 16 | } |
| 17 | 17 | |