Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

Commit

Permalink
Remove info function in Entity. Bumped version.
Browse files Browse the repository at this point in the history
  • Loading branch information
hperrin committed Oct 25, 2017
1 parent 91b76d8 commit cfa671e
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 94 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "sciactive/nymph-server",
"description": "Powerful object data storage and querying for collaborative web apps.",
"version": "2.1.0",
"time": "2017-10-24",
"version": "2.2.0",
"time": "2017-10-25",
"homepage": "http://nymph.io/",
"type": "library",
"authors": [
Expand Down Expand Up @@ -49,7 +49,7 @@
"sciactive/requirephp": "~1.3"
},
"require-dev": {
"sciactive/hookphp": "~2.0",
"sciactive/hookphp": "~2.0.1",
"phpunit/phpunit": "^6.1"
}
}
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 0 additions & 26 deletions src/DataObjectInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,6 @@ public function equals(&$object);
* $array is not an array.
*/
public function inArray($array, $strict = false);
/**
* Get info about an object.
*
* This function is meant to provide a way to represent an object even when
* nothing is known about it.
*
* There are a few common types that most entities/objects should provide.
* - name - The name of the object.
* - type - The type of data this object represents. (E.g., "user",
* "customer", "page".) This can be localized.
* - types - The same as above, but pluralized. (E.g., "users".)
* - url_view - The URL where this object can be viewed. If the currently
* logged in user doesn't have the ability to view it, or there is no URL
* to view it, this should return null.
* - url_edit - The same as above, but for editing.
* - url_list - The URL where this object, and others like it, can be found.
* (E.g., to a list of users.)
* - icon - The class to apply for an icon representing this object.
* (Generally a Font Awesome or Bootstrap class.)
* - image - The URL to an image representing this object.
*
* @param string $type The type of information being requested.
* @return mixed The information, or null if the information doesn't exist or
* can't be returned.
*/
public function info($type);
/**
* Perform a less strict comparison of this object to another.
*
Expand Down
28 changes: 16 additions & 12 deletions src/Drivers/DriverTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function checkData(
(
(
!isset($data[$cur_value[0]])
&& !$cur_value[1]
&& $cur_value[1] == null
)
|| (
isset($data[$cur_value[0]])
Expand Down Expand Up @@ -203,17 +203,19 @@ public function checkData(
'~',
'[[:<:]]',
'[[:>:]]',
'[:alnum:]]',
'[:alpha:]]',
'[:blank:]]',
'[:cntrl:]]',
'[:digit:]]',
'[:graph:]]',
'[:lower:]]',
'[:print:]]',
'[:punct:]]',
'[:space:]]',
'[:upper:]]',
'[:alnum:]',
'[:alpha:]',
'[:ascii:]',
'[:blank:]',
'[:cntrl:]',
'[:digit:]',
'[:graph:]',
'[:lower:]',
'[:print:]',
'[:punct:]',
'[:space:]',
'[:upper:]',
'[:word:]',
'[:xdigit:]',
],
[
Expand All @@ -222,6 +224,7 @@ public function checkData(
'(?<=\w)\b',
'[A-Za-z0-9]',
'[A-Za-z]',
'[\x00-\x7F]',
'\s',
'[\000\001\002\003\004\005\006\007\008\009\010\011\012\013\014\015\016\017\018\019\020\021\022\023\024\025\026\027\028\029\030\031\032\033\034\035\036\037\177]',
'\d',
Expand All @@ -231,6 +234,7 @@ public function checkData(
'[!"#$%&\'()*+,\-./:;<=>?@[\\\]^_`{|}\~]',
'[\t\n\x0B\f\r ]',
'[A-Z]',
'[A-Za-z0-9_]',
'[0-9A-Fa-f]',
],
$cur_value[1]
Expand Down
33 changes: 0 additions & 33 deletions src/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@
* @property int $guid The entity's Globally Unique ID.
* @property int $cdate The entity's creation date, as a high precision Unix timestamp. The value is rounded to the ten thousandths digit.
* @property int $mdate The entity's modification date, as a high precision Unix timestamp. The value is rounded to the ten thousandths digit.
* @property string $name An optional name of the entity. This will be provided
* in the "info" property of the JS object.
*/
class Entity implements EntityInterface {
const ETYPE = 'entity';
Expand Down Expand Up @@ -708,17 +706,6 @@ public function inArray($array, $strict = false) {
return $this->arraySearch($array, $strict) !== false;
}

public function info($type) {
if ($type == 'name' && isset($this->name)) {
return $this->name;
} elseif ($type == 'type') {
return 'entity';
} elseif ($type == 'types') {
return 'entities';
}
return null;
}

public function is(&$object) {
if ($this->isASleepingReference) {
$this->referenceWake();
Expand Down Expand Up @@ -752,26 +739,6 @@ public function jsonSerialize($clientClassName = true) {
$object->cdate = $this->cdate;
$object->mdate = $this->mdate;
$object->tags = $this->tags;
$object->info = [
'name' => $this->info('name'),
'type' => $this->info('type'),
'types' => $this->info('types')
];
if ($this->info('url_view')) {
$object->info['url_view'] = $this->info('url_view');
}
if ($this->info('url_edit')) {
$object->info['url_edit'] = $this->info('url_edit');
}
if ($this->info('url_list')) {
$object->info['url_list'] = $this->info('url_list');
}
if ($this->info('icon')) {
$object->info['icon'] = $this->info('icon');
}
if ($this->info('image')) {
$object->info['image'] = $this->info('image');
}
$object->data = [];
foreach ($this->getData(true) as $key => $val) {
if (!in_array($key, $this->privateData)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Nymph.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @link http://nymph.io/
*/
class Nymph {
const VERSION = '2.1.0';
const VERSION = '2.2.0';

public static function __callStatic($name, $args) {
return call_user_func_array(array(RequirePHP::_('Nymph'), $name), $args);
Expand Down
11 changes: 0 additions & 11 deletions testing/TestModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,6 @@ public function __construct($id = 0) {
parent::__construct($id);
}

public function info($type) {
if ($type == 'name' && isset($this->name)) {
return $this->name;
} elseif ($type == 'type') {
return 'test';
} elseif ($type == 'types') {
return 'tests';
}
return null;
}

public function useProtectedData() {
$this->whitelistData = false;
$this->protectedData = ['number'];
Expand Down
3 changes: 1 addition & 2 deletions testing/tests/EntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,7 @@ public function testJSON($arr) {
$this->assertJsonStringEqualsJsonString(
'{"guid":' . $testEntity->guid.',"cdate":' .
json_encode($testEntity->cdate) . ',"mdate":' .
json_encode($testEntity->mdate) . ',"tags":["test"],"info":' .
'{"name":"Entity Test","type":"test","types":"tests"},"data":' .
json_encode($testEntity->mdate) . ',"tags":["test"],"data":' .
'{"reference":["nymph_entity_reference",' .
$arr['refGuid'] . ',"TestModel"],"ref_array":[{"entity":' .
'["nymph_entity_reference",' .
Expand Down

0 comments on commit cfa671e

Please sign in to comment.