Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Merging develop to master in preparation for 1.4.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Jul 7, 2016
2 parents 45fec7b + 8f6a053 commit 6126e58
Show file tree
Hide file tree
Showing 179 changed files with 3,645 additions and 34,728 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
composer.lock
vendor/
45 changes: 36 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,60 @@ language: php
cache:
directories:
- $HOME/.composer/cache
- vendor

env:
global:
- COMPOSER_ARGS="--no-interaction --ignore-platform-reqs"

matrix:
fast_finish: true
include:
- php: 5.5
- php: 5.6
env:
- DEPS=lowest
- php: 5.6
env:
- EXECUTE_CS_CHECK=true
- DEPS=locked
- php: 5.6
env:
- EXECUTE_COVERAGE=true
- DEPS=latest
- php: 7
env:
- DEPS=lowest
- php: 7
env:
- DEPS=locked
- CS_CHECK=true
- php: 7
env:
- DEPS=latest
- php: hhvm
env:
- DEPS=lowest
- php: hhvm
env:
- DEPS=locked
- php: hhvm
env:
- DEPS=latest
allow_failures:
- php: 7
- php: hhvm

notifications:
irc: "irc.freenode.org#apigility-dev"
email: false

before_install:
- if [[ $EXECUTE_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
- composer self-update
- if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
- travis_retry composer self-update

install:
- travis_retry composer install --no-interaction --ignore-platform-reqs --prefer-source
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi
- travis_retry composer install $COMPOSER_ARGS
- composer show

script:
- ./vendor/bin/phpunit
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/phpcs ; fi
- composer test
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi
59 changes: 59 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,65 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 1.4.0 - TBD

### Added

- [#142](https://github.com/zfcampus/zf-hal/pull/142) and
[#145](https://github.com/zfcampus/zf-hal/pull/145) add support for Zend
Framework v3 component releases, retaining support for v2 versions as well;
specifically, zend-eventmanager, zend-mvc, zend-stdlib, and
zend-servicemanager v3 may now be used with this module.
- [#142](https://github.com/zfcampus/zf-hal/pull/142) and
[#145](https://github.com/zfcampus/zf-hal/pull/145) add support for PHP 7.
- [#99](https://github.com/zfcampus/zf-hal/pull/99) adds accessors for the
`$entity` and `$id` properties of `ZF\Hal\Entity`.
- [#124](https://github.com/zfcampus/zf-hal/pull/124) adds a new interface
`ZF\Hal\Link\SelfLinkInjectorInterface` and default implementation
`ZF\Hal\Link\SelfLinkInjector`; these are now used as collaborators to the
`Hal` plugin to simplify internal logic, and allow users to provide alternate
strategies for generating the `self` relational link.
- [#125](https://github.com/zfcampus/zf-hal/pull/125) adds a new service,
`ZF\Hal\Link\LinkUrlBuilder`. This class composes the `ServerUrl` and `Url`
view helpers in order to provide the functionality required to build a
route-based link URL. The `Hal` plugin now consumes this instead of
implementing the logic internally.

The upshot is: you can replace the URL generation semantics for your
application entirely by pointing the service to your own implementation.
- [#125](https://github.com/zfcampus/zf-hal/pull/125) adds service factories for
each of the `LinkExtractor` and `LinkCollectionExtractor`, which now allows
users to provide substitutions for their functionality. (Extractors pull links
and link collections in order to generate the relational links for a HAL-JSON
payload.)
- [#139](https://github.com/zfcampus/zf-hal/pull/139) adds the new method
`Hal::resetEntityHashStack()`; this method can be used when rendering multiple
responses and/or payloads within the same request cycle, in order to allow
re-using the same entity instances (normally, they would be skipped when
discovered on subsequent iterations).

### Deprecated

- [#99](https://github.com/zfcampus/zf-hal/pull/99) deprecates usage of property
access on `ZF\Hal\Entity` to retrieve the identifier and underlying entity
instance.
- [#125](https://github.com/zfcampus/zf-hal/pull/125) deprecates the usage of
`Hal::setServerUrlHelper()` and `Hal::setUrlHelper()`; these will each now
raise an exception indicating the user should use a `LinkUrlBuilder` for URL
generation instead.
- [#125](https://github.com/zfcampus/zf-hal/pull/125) deprecates passing a
`ServerUrlHelper` and `UrlHelper` to the constructor of
`ZF\Hal\Exctractor\LinkExtractor`; it now expects a `LinkUrlBuilder` instance
instead. (This class is primarily an internal detail of the `Hal` plugin.)

### Removed

- [#145](https://github.com/zfcampus/zf-hal/pull/145) removes support for PHP 5.5.

### Fixed

- Nothing.

## 1.3.1 - 2016-07-07

### Added
Expand Down
43 changes: 43 additions & 0 deletions CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Contributor Code of Conduct

The Zend Framework project adheres to [The Code Manifesto](http://codemanifesto.com)
as its guidelines for contributor interactions.

## The Code Manifesto

We want to work in an ecosystem that empowers developers to reach their
potential — one that encourages growth and effective collaboration. A space that
is safe for all.

A space such as this benefits everyone that participates in it. It encourages
new developers to enter our field. It is through discussion and collaboration
that we grow, and through growth that we improve.

In the effort to create such a place, we hold to these values:

1. **Discrimination limits us.** This includes discrimination on the basis of
race, gender, sexual orientation, gender identity, age, nationality, technology
and any other arbitrary exclusion of a group of people.
2. **Boundaries honor us.** Your comfort levels are not everyone’s comfort
levels. Remember that, and if brought to your attention, heed it.
3. **We are our biggest assets.** None of us were born masters of our trade.
Each of us has been helped along the way. Return that favor, when and where
you can.
4. **We are resources for the future.** As an extension of #3, share what you
know. Make yourself a resource to help those that come after you.
5. **Respect defines us.** Treat others as you wish to be treated. Make your
discussions, criticisms and debates from a position of respectfulness. Ask
yourself, is it true? Is it necessary? Is it constructive? Anything less is
unacceptable.
6. **Reactions require grace.** Angry responses are valid, but abusive language
and vindictive actions are toxic. When something happens that offends you,
handle it assertively, but be respectful. Escalate reasonably, and try to
allow the offender an opportunity to explain themselves, and possibly correct
the issue.
7. **Opinions are just that: opinions.** Each and every one of us, due to our
background and upbringing, have varying opinions. The fact of the matter, is
that is perfectly acceptable. Remember this: if you respect your own
opinions, you should respect the opinions of others.
8. **To err is human.** You might not intend it, but mistakes do happen and
contribute to build experience. Tolerate honest mistakes, and don't hesitate
to apologize if you make one yourself.
22 changes: 14 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,31 @@ First, use [Composer](https://getcomposer.org) to install all dependencies:
$ composer install
```

To run tests, use the PHPUnit executable installed by Composer:
To run tests:

```console
$ ./vendor/bin/phpunit
$ composer test
```

## CODING STANDARDS

While Apigility uses Zend Framework 2 coding standards, in practice, we check
standards using [php-cs-fixer](https://github.com/fabpot/PHP-CS-Fixer) (which is
installed via Composer with other dependencies). To check for CS issues:
standards against PSR-1/2. To check for CS issues:

```console
$ ./vendor/bin/php-cs-fixer fix . --dry-run
$ composer cs-check
```

This will report CS issues. Alternately, you can have the tool fix them for you
by omitting the `--dry-run` switch:
This will report CS issues. You can also attempt to fix many reported errors
automatically:

```console
$ ./vendor/bin/php-cs-fixer fix .
$ composer cs-fix
```

If you use `cs-fix` to fix issues, make certain you add and commit any files
changed!

## Conduct

Please see our [CONDUCT.md](CONDUCT.md) to understand expected behavior when interacting with others in the project.
19 changes: 10 additions & 9 deletions LICENSE.txt → LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
Copyright (c) 2014, Zend Technologies USA, Inc.
Copyright (c) 2014-2016, Zend Technologies USA, Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of Zend Technologies USA, Inc. nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
- Neither the name of Zend Technologies USA, Inc. nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Expand Down
61 changes: 34 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ Installation
Run the following `composer` command:

```console
$ composer require "zfcampus/zf-hal:~1.0-dev"
$ composer require zfcampus/zf-hal
```

Alternately, manually add the following to your `composer.json`, in the `require` section:

```javascript
"require": {
"zfcampus/zf-hal": "~1.0-dev"
"zfcampus/zf-hal": "^1.4"
}
```

Expand All @@ -37,16 +37,21 @@ Finally, add the module name to your project's `config/application.config.php` u
key:

```php
return array(
return [
/* ... */
'modules' => array(
'modules' => [
/* ... */
'ZF\Hal',
),
],
/* ... */
);
];
```

> ### zf-component-installer
>
> If you use [zf-component-installer](https://github.com/zendframework/zf-component-installer),
> that plugin will install zf-hal as a module for you.
Configuration
=============

Expand Down Expand Up @@ -102,15 +107,15 @@ Each class in the metadata map may contain one or more of the following configur
The `links` property is an array of arrays, each with the following structure:

```php
array(
[
'rel' => 'link relation',
'url' => 'string absolute URI to use', // OR
'route' => array(
'route' => [
'name' => 'route name for this link',
'params' => array( /* any route params to use for link generation */ ),
'options' => array( /* any options to pass to the router */ ),
),
),
'params' => [ /* any route params to use for link generation */ .,
'options' => [ /* any options to pass to the router */ .,
.,
.,
// repeat as needed for any additional relational links
```

Expand All @@ -119,7 +124,9 @@ array(
The options key is used to configure general options of the Hal plugin.
For now we have only one option available who contains the following configuration key:

- `use_proxy` - boolean; set to `true` when you are using a proxy (for using HTTP_X_FORWARDED_PROTO, HTTP_X_FORWARDED_HOST, and HTTP_X_FORWARDED_PROTO instead of SSL HTTPS, HTTP_HOST, SERVER_PORT)
- `use_proxy` - boolean; set to `true` when you are using a proxy (for using
`HTTP_X_FORWARDED_PROTO`, `HTTP_X_FORWARDED_HOST`, and
`HTTP_X_FORWARDED_PROTO` instead of `SSL HTTPS`, `HTTP_HOST, SERVER_PORT`)

### System Configuration

Expand All @@ -128,16 +135,16 @@ a ZF2-based application.

```php
// Creates a "HalJson" selector for use with zfcampus/zf-content-negotiation
'zf-content-negotiation' => array(
'selectors' => array(
'HalJson' => array(
'ZF\Hal\View\HalJsonModel' => array(
'zf-content-negotiation' => [
'selectors' => [
'HalJson' => [
'ZF\Hal\View\HalJsonModel' => [
'application/json',
'application/*+json',
),
),
),
),
],
],
],
],
```

ZF2 Events
Expand Down Expand Up @@ -173,24 +180,24 @@ class Module

// The HAL plugin's EventManager instance does not compose a SharedEventManager,
// so you must attach directly to it.
$hal->getEventManager()->attach('renderEntity', array($this, 'onRenderEntity'));
$hal->getEventManager()->attach('renderEntity', [$this, 'onRenderEntity']);
}

public function onRenderEntity($e)
{
$entity = $e->getParam('entity');
if (! $entity->entity instanceof SomeTypeIHaveDefined) {
if (! $entity->getEntity() instanceof SomeTypeIHaveDefined) {
// do nothing
return;
}

// Add a "describedBy" relational link
$entity->getLinks()->add(\ZF\Hal\Link\Link::factory(array(
$entity->getLinks()->add(\ZF\Hal\Link\Link::factory([
'rel' => 'describedBy',
'route' => array(
'route' => [
'name' => 'my/api/docs',
),
)));
],
]));
}
}
```
Expand Down
Loading

0 comments on commit 6126e58

Please sign in to comment.