afosto / api-client Goto Github PK
View Code? Open in Web Editor NEWOfficial Afosto API client
Home Page: https://wiki.afosto.com
Official Afosto API client
Home Page: https://wiki.afosto.com
When trying to do $model->findPage()
, the notice Use of undefined constant PAGE_SIZE - assumed 'PAGE_SIZE' in vendor/afosto/api-client/src/Api/Pagination.php on line 60
is generated.
This issue is caused by:
findPage()
not passing the provided $pageSize
parameter to the Paginator constructor because PaginationTrait->getPagination()
doesn't support the attribute.PAGE_SIZE
constant despite not being certain whether it has been defined.Recommendation:
I'm unable to use any storage adapter in my project. My code looks as follows:
require_once __DIR__.'/vendor/autoload.php';
$storage = new Afosto\ApiClient\Components\Storage\FileStorage([
'directory' => $app['base_path'] . '/tmp/'
]);
\Afosto\ApiClient\App::run($storage, $app['config']['api_token'], $app['config']['api_secret']);
In response, I get the following exception:
Fatal error: Class 'Afosto\ApiClient\Components\Storage\FileStorage' not found
I suspect this may have something to do with using PSR-4 autoloading on multiple directories at the same time, confusing the autoloader. Many libraries simply use one base directory and make the namespace tree match the directory tree, rather than using a Yii-like "we have specific directories for everything and load the contents of all of them manually".
For example, I want to paginate over a list of models and compare the results of the current page to the results from the first page. To do this, I write the following snippet:
$model = \Afosto\ApiClient\Models\Products\Product::model();
foreach($model->paginate() as $products){
$model->findPage(1);
}
Because paginate()
and findPage()
use the same paginator instance, this will result in an endless loop because findPage(1)
will always reset the paginator to page 1.
Another potential issue with sharing the paginator is that if paginate
receives a certain page size and findPage
defines a different page size, then paginate
will also use the first page size, which could cause unpredictable behavior.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.