-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial implementation of Agile API #1
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1 +/- ##
=========================================
Coverage ? 49.01%
Complexity ? 41
=========================================
Files ? 1
Lines ? 102
Branches ? 0
=========================================
Hits ? 50
Misses ? 52
Partials ? 0
Continue to review full report at Codecov.
|
} | ||
} | ||
session_start(); | ||
$db = new \atk4\data\Persistence_SQL('mysql:dbname=atk4;host=localhost', 'root', 'root'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this - hard-coded db name and user/password. Should be some kind of config.php file somewhere in root or something like that. Also where is DB build script which create country table?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably will move into memory / sqlite.
|
||
$api = new \atk4\api\Api(); | ||
|
||
class Country extends \atk4\data\Model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably test model should be moved somewhere outside test script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a first quick test. Probably would remove this file long-term or clean it up.
src/Api.php
Outdated
|
||
if ($this->emitter) { | ||
// cannot do anything about it | ||
$emitter->emit($this->response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be $this->emitter here
src/Api.php
Outdated
class Api | ||
{ | ||
// @var \Zend\Diactoros\ServerRequest Request object | ||
public $request; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More likely these two (request and response) can be set as protected too, but ... maybe they can be used in some way outside of the class too for debug for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm using them publicly though.
src/Api.php
Outdated
|
||
return false; | ||
|
||
/* never used code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never used code
src/Api.php
Outdated
|
||
$vars = []; | ||
|
||
// $sanity = 50; unused variable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused variable
} | ||
|
||
// no emitter (is that possible at all ?) | ||
return $ret; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible at all to not have emitter defined? it's always defined in constructor.
in what case i exclusively would want to set $api->emitter = false
like in test script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, if we don't want response to be sent out through echo. That's a valid situation when we doing unit tests.
src/Api.php
Outdated
return !$model->load($id)->delete()->loaded(); | ||
}); | ||
|
||
$this->post($pattern.'/', function () use ($model) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we need '/'
here ?
} | ||
|
||
$api = new \atk4\api\Api($request); | ||
$api->emitter = false; // don't emmit response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i changed emitter property to protected so this will fail. what's the use-case when we don't want emitter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep. can you change it back please?
Comments addressed, proceeding with initial merge |
Wow, this already works pretty well!