Giter Site home page Giter Site logo

xom's Introduction

xom

TYPO3-Extension providing service classes to work with the xom REST API. More information about xom can be found here: https://www.myview.de/xom-api

Installation

Just add this extension using composer require medienreaktor/xom and make sure to configure the installation-wide extension configuration:

Features and usage

The XomService-class includes

  • Authentication
  • Caching
  • Localization

for the xom REST API. Use it in your own extension by extending the XomService-class and adding your API calls.

Example

Add your own service-class for fetching product data:

<?php
namespace YourVendor\XomProducts\Service;

class XomProductsService extends \Medienreaktor\Xom\Service\XomService
{
    const REQUEST_PRODUCTS = 'products';
    const REQUEST_PRODUCTS_ID = 'products/{id}';

    public function listProducts() {
        return $this->apiCall(self::REQUEST_PRODUCTS);
    }

    public function findProductById($identifier) {
        return $this->apiCall(self::REQUEST_PRODUCTS_ID, $identifier);
    }
}

Caching of requests and responses will be done automatically. For better caching control, consider implementing additional caching yourself.

If you want to opt-out of the default caching, see the parameters of the apiCall-method:

Parameter Type Description Default
$uri string URI for API call, required
$identifier string Node identifier, optional NULL
$params array Request parameters []
$localized boolean Localize responses? TRUE
$cached boolean Cache responses? TRUE
$method string HTTP method 'GET'

In your controller, inject your service-class, perform your calls and assign the results to the view:

<?php
namespace YourVendor\XomProducts\Controller;

class ProductController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
    /**
     * xomProductsService
     *
     * @var \YourVendor\XomProducts\Service\XomProductsService
     * @TYPO3\CMS\Extbase\Annotation\Inject
     */
    protected $xomProductsService = NULL;

    /**
     * action list
     *
     * @return void
     */
    public function listAction() {
        $products = $this->xomProductsService->listProducts();
        $this->view->assign('products', $products);
    }
}

Support

This extension is provided without warranty of any kind and released under the GPL-3 license. For professional support and development, please contact us: https://www.medienreaktor.de

xom's People

Contributors

danielkestler avatar

Stargazers

Sean P. Myrick V19.1.7.2 avatar

Watchers

 avatar  avatar Sean P. Myrick V19.1.7.2 avatar

Forkers

seanpm2001

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.