Skip to content
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

Merged
merged 11 commits into from
Oct 23, 2017
Merged

Initial implementation of Agile API #1

merged 11 commits into from
Oct 23, 2017

Conversation

romaninsh
Copy link
Member

Wow, this already works pretty well!

@codecov-io
Copy link

codecov-io commented Oct 17, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@08ae4cd). Click here to learn what that means.
The diff coverage is 49.01%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master       #1   +/-   ##
=========================================
  Coverage          ?   49.01%           
  Complexity        ?       41           
=========================================
  Files             ?        1           
  Lines             ?      102           
  Branches          ?        0           
=========================================
  Hits              ?       50           
  Misses            ?       52           
  Partials          ?        0
Impacted Files Coverage Δ Complexity Δ
src/Api.php 49.01% <49.01%> (ø) 41 <41> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 08ae4cd...87d3b91. Read the comment docs.

@DarkSide666 DarkSide666 self-requested a review October 18, 2017 20:54
}
}
session_start();
$db = new \atk4\data\Persistence_SQL('mysql:dbname=atk4;host=localhost', 'root', 'root');
Copy link
Member

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?

Copy link
Member Author

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
Copy link
Member

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.

Copy link
Member Author

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);
Copy link
Member

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;
Copy link
Member

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.

Copy link
Member Author

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
Copy link
Member

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
Copy link
Member

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;
Copy link
Member

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?

Copy link
Member Author

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) {
Copy link
Member

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
Copy link
Member

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?

Copy link
Member Author

@romaninsh romaninsh Oct 20, 2017

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?

@romaninsh
Copy link
Member Author

Comments addressed, proceeding with initial merge

@romaninsh romaninsh merged commit ade49be into master Oct 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants