GithubHelp home page GithubHelp logo

simme / services_oop Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hugowetterberg/services_oop

1.0 0.0 1.0 118 KB

Utility functions for working with services in a more OOP-friendly manner

PHP 100.00%

services_oop's Introduction

README

services_oop allows declarative definition of resource-based services through class declarations.

Example

This is a incomplete example of how a resource could be implemented.

<?php

/**
 * Class that defines the event resource
 *
 * @Relationship(name='occasions', controller='retrieveOccasions')
 */
class EventResource {
  /**
   * Creates a event
   *
   * @param object $event ["data"]
   * @return object
   *
   * @Access(callback='_event_resource_access', args={'create'}, appendArgs=true)
   */
  public static function create($event) {
    // Do your thing here
  }

  /**
   * Retrieves a event
   *
   * @param int $nid ["path","0"]
   *  The nid of the event to get
   * @return object
   *
   * @Access(callback='_event_resource_access', args={'view'}, appendArgs=true)
   * @Model(class='ResourceFeedModel', implementation='EventResourceFeedModel')
   */
  public static function retrieve($nid) {
    // Do your thing here
  }

  /**
   * Updates a event
   *
   * @param int $nid ["path","0"]
   *  The nid of the event to update
   * @param object $event ["data"]
   *  The event object
   * @return object
   *
   * @Access(callback='_event_resource_access', args={'update'}, appendArgs=true)
   */
  public static function update($nid, $event) {
    // Do your thing here
  }

  /**
   * Deletes a event
   *
   * @param int $nid ["path","0"]
   *  The nid of the event to get
   * @return bool
   *
   * @Access(callback='_event_resource_access', args={'delete'}, appendArgs=true)
   */
  public static function delete($nid) {
    // Do your thing here
  }

  /**
   * Retrieves a listing of events
   *
   * @param int $page ["param","page"]
   * @param string $fields ["param","fields"]
   * @param array $params ["param"]
   * @return array
   *
   * @Access(callback='user_access', args={'access content'}, appendArgs=false)
   * @Model(class='ResourceFeedModel', implementation='EventResourceFeedModel')
   * @Model(class='ResourceTimeFeedModel', implementation='EventResourceFeedModel')
   */
  public static function index($page=0, $fields=array(), $params=array()) {
    // Do your thing here
  }

  /**
   * Controller method for getting occasions for a event
   *
   * @param int $nid ["path","0"]
   *  The nid of the event to get occasions for
   * @param int $page ["param","page"]
   * @return array
   *
   * @Model(class='ResourceFeedModel', implementation='EventOccasionsFeedModel')
   * @Model(class='ResourceTimeFeedModel', implementation='EventOccasionsFeedModel')
   */
  public static function retrieveOccasions($nid, $page=0) {
    // Do your thing here
  }
}

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.